From b979295baa5e7ce3031856a5ca1dec37d20480e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miloslav=20H=C5=AFla?= Date: Thu, 10 Mar 2011 14:33:34 +0100 Subject: [PATCH] implemented escapeLike() for PostgreSQL driver --- dibi/drivers/postgre.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/dibi/drivers/postgre.php b/dibi/drivers/postgre.php index fb897b3e..0eab314d 100644 --- a/dibi/drivers/postgre.php +++ b/dibi/drivers/postgre.php @@ -319,7 +319,14 @@ class DibiPostgreDriver extends DibiObject implements IDibiDriver, IDibiResultDr */ public function escapeLike($value, $pos) { - throw new NotImplementedException; + if ($this->escMethod) { + $value = pg_escape_string($this->connection, $value); + } else { + $value = pg_escape_string($value); + } + + $value = strtr($value, array( '%' => '\\\\%', '_' => '\\\\_')); + return ($pos <= 0 ? "'%" : "'") . $value . ($pos >= 0 ? "%'" : "'"); }