previous->whereAdd() (Previous) (Next) ->limit()next

View this page in Last updated: Sun, 21 Jun 2009
English | Brazilian Portuguese | Chinese | Dutch | French | German | Hungarian | Japanese | Polish | Russian | Spanish | Turkish

->escape()

->escape() – Like クエリで使用する文字列をエスケープする

Synopsis

void $DB_DataObject->escape ( string $value )

Description

Pear DB の quote と同様、値をクオートがなくなるようエスケープしますので、 LIKE クエリで使用することができます。

Parameter

  • string $value - エスケープしたい文字列を指定します。

Note

This function can not be called statically.

Example

LIKE の文字列をエスケープする

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

結果の SQL


SELECT * FROM PERSON WHERE name LIKE '%o\'brian%'
previous->whereAdd() (Previous) (Next) ->limit()next

Download Documentation Last updated: Sun, 21 Jun 2009
Do you think that something on this page is wrong? Please file a bug report or add a note.
User Notes:
Note by: alan@akbkhome.com
there is another 2nd argument bool likeEscape, which escapes like queries (eg. _ and %)