1
0
mirror of https://github.com/dg/dibi.git synced 2025-08-08 07:06:52 +02:00

Postgre: fixed %like escaping [Closes #159]

This commit is contained in:
Miloslav Hůla
2015-01-22 17:21:44 +01:00
parent 97b50bd243
commit 91e2d76a0a
3 changed files with 28 additions and 5 deletions

View File

@@ -310,8 +310,9 @@ class DibiPostgreDriver extends DibiObject implements IDibiDriver, IDibiResultDr
*/
public function escapeLike($value, $pos)
{
$bs = pg_escape_string($this->connection, '\\'); // standard_conforming_strings = on/off
$value = pg_escape_string($this->connection, $value);
$value = strtr($value, array( '%' => '\\\\%', '_' => '\\\\_'));
$value = strtr($value, array('%' => $bs . '%', '_' => $bs . '_', '\\' => '\\\\'));
return ($pos <= 0 ? "'%" : "'") . $value . ($pos >= 0 ? "%'" : "'");
}