->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

  • string $value - the string you want to escape

Note

This function can not be called statically.

Example

Escaping a LIKE string

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

Sample SQL

        
SELECT * FROM PERSON WHERE name LIKE '%o\'brian%'
Add WHERE statement (Previous) Set limit (Next)
Last updated: Fri, 24 Oct 2014 — Download Documentation
Do you think that something on this page is wrong? Please file a bug report or add a note.
View this page in:

User Notes:

Note by: alan@akbkhome.com
there is another 2nd argument bool likeEscape, which escapes like queries (eg. _ and %)