summaryrefslogtreecommitdiff
path: root/adodb-active-recordx.inc.php
diff options
context:
space:
mode:
Diffstat (limited to 'adodb-active-recordx.inc.php')
-rw-r--r--adodb-active-recordx.inc.php54
1 files changed, 31 insertions, 23 deletions
diff --git a/adodb-active-recordx.inc.php b/adodb-active-recordx.inc.php
index 18e2a189..789c9930 100644
--- a/adodb-active-recordx.inc.php
+++ b/adodb-active-recordx.inc.php
@@ -762,28 +762,36 @@ class ADODB_Active_Record {
}
// quote data in where clause
- function doquote(&$db, $val,$t)
+ function doQuote($db, $val, $t)
{
- switch($t) {
- case 'D':
- case 'T':
- if (empty($val)) {
- return 'null';
- }
- case 'C':
- case 'X':
- if (is_null($val)) {
- return 'null';
- }
- if (strlen($val)>0 &&
- (strncmp($val,"'",1) != 0 || substr($val,strlen($val)-1,1) != "'")
- ) {
- return $db->qstr($val);
- break;
- }
- default:
- return $val;
- break;
+ switch ($t) {
+ /** @noinspection PhpMissingBreakStatementInspection */
+ case 'L':
+ if (strpos($db->databaseType, 'postgres') !== false) {
+ return $db->qstr($val);
+ }
+ case 'D':
+ /** @noinspection PhpMissingBreakStatementInspection */
+ case 'T':
+ if (empty($val)) {
+ return 'null';
+ }
+ case 'B':
+ case 'N':
+ case 'C':
+ /** @noinspection PhpMissingBreakStatementInspection */
+ case 'X':
+ if (is_null($val)) {
+ return 'null';
+ }
+ if ('' === (string)$val) {
+ return "''";
+ }
+ if (substr($val, 0, 1) != "'" || substr($val,-1) != "'") {
+ return $db->qstr($val);
+ }
+ default:
+ return $val;
}
}
@@ -796,7 +804,7 @@ class ADODB_Active_Record {
foreach($keys as $k) {
$f = $table->flds[$k];
if ($f) {
- $parr[] = $k.' = '.$this->doquote($db,$this->$k,$db->MetaType($f->type));
+ $parr[] = $k . ' = ' . $this->doQuote($db, $this->$k, $db->MetaType($f->type));
}
}
return implode(' and ', $parr);
@@ -1081,7 +1089,7 @@ class ADODB_Active_Record {
continue;
}
$t = $db->MetaType($fld->type);
- $arr[$name] = $this->doquote($db,$val,$t);
+ $arr[$name] = $this->doQuote($db, $val, $t);
$valarr[] = $val;
}