->escape()

->escape() -- Escape a string for use with Like queries

Synopsis

void $DB_DataObject->escape (string $value)

Description

Similar to Pear DB's quote it will escape a value, without the quotes, so it can be used with a LIKE query.

Parameter

Note

This function can not be called statically.

Example

Example 39-1. Escaping a LIKE string


<?php
$person = new DataObjects_Person;
$person->whereAdd("name LIKE '%" $person->escape("o'brian") . "%'");
$person->find();
?>

Example 39-2. Sample SQL

SELECT * FROM PERSON WHERE name LIKE '%o\'brian%'