From: Domas Mituzas Date: Tue, 9 Aug 2005 13:25:42 +0000 (+0000) Subject: add escaping routines for LIKE: db::escapeLike($s) X-Git-Tag: 1.6.0~2040 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/password.php?a=commitdiff_plain;h=6de72cbbfec4883dec23da4b59cbb1b4b82faf29;p=lhc%2Fweb%2Fwiklou.git add escaping routines for LIKE: db::escapeLike($s) --- diff --git a/includes/Database.php b/includes/Database.php index 8d1e37da61..543d4caf65 100644 --- a/includes/Database.php +++ b/includes/Database.php @@ -1128,6 +1128,15 @@ class Database { } } + /** + * Escape string for safe LIKE usage + */ + function escapeLike( $s ) { + $s=$this->strencode( $s ); + $s=str_replace(array('%','_'),array('\%','\_'),$s); + return $s; + } + /** * Returns an appropriately quoted sequence value for inserting a new row. * MySQL has autoincrement fields, so this is just NULL. But the PostgreSQL