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

Postgre: fixed %like escaping [Closes #159]

This commit is contained in:
Miloslav Hůla
2015-01-22 17:21:44 +01:00
committed by David Grudl
parent a57f3dfc83
commit 8a5eddfabc

View File

@@ -300,8 +300,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 ? "%'" : "'");
}