mirror of
https://github.com/dg/dibi.git
synced 2025-08-07 14:46:50 +02:00
Postgre: fixed %like escaping [Closes #159]
This commit is contained in:
committed by
David Grudl
parent
a57f3dfc83
commit
8a5eddfabc
@@ -300,8 +300,9 @@ class DibiPostgreDriver extends DibiObject implements IDibiDriver, IDibiResultDr
|
|||||||
*/
|
*/
|
||||||
public function escapeLike($value, $pos)
|
public function escapeLike($value, $pos)
|
||||||
{
|
{
|
||||||
|
$bs = pg_escape_string($this->connection, '\\'); // standard_conforming_strings = on/off
|
||||||
$value = pg_escape_string($this->connection, $value);
|
$value = pg_escape_string($this->connection, $value);
|
||||||
$value = strtr($value, array( '%' => '\\\\%', '_' => '\\\\_'));
|
$value = strtr($value, array('%' => $bs . '%', '_' => $bs . '_', '\\' => '\\\\'));
|
||||||
return ($pos <= 0 ? "'%" : "'") . $value . ($pos >= 0 ? "%'" : "'");
|
return ($pos <= 0 ? "'%" : "'") . $value . ($pos >= 0 ? "%'" : "'");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user