diff options
Diffstat (limited to 'adodb-active-record.inc.php')
| -rw-r--r-- | adodb-active-record.inc.php | 76 |
1 files changed, 31 insertions, 45 deletions
diff --git a/adodb-active-record.inc.php b/adodb-active-record.inc.php index 08f7ca8d..ea1d4ed3 100644 --- a/adodb-active-record.inc.php +++ b/adodb-active-record.inc.php @@ -717,35 +717,36 @@ class ADODB_Active_Record { } // quote data in where clause - function doquote(&$db, $val,$t) + function doQuote($db, $val, $t) { - switch($t) { - case 'L': - if (strpos($db->databaseType,'postgres') !== false) { - return $db->qstr($val); - } - case 'D': - case 'T': - if (empty($val)) { - return 'null'; - } - case 'B': - case 'N': - 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; } } @@ -759,27 +760,12 @@ class ADODB_Active_Record { $f = $table->flds[$k]; if ($f) { $columnName = $this->nameQuoter($db,$k); - $parr[] = $columnName.' = '.$this->doquote($db,$this->$k,$db->MetaType($f->type)); + $parr[] = $columnName . ' = ' . $this->doQuote($db, $this->$k, $db->MetaType($f->type)); } } return implode(' AND ', $parr); } - - function _QName($n,$db=false) - { - if (!ADODB_Active_Record::$_quoteNames) { - return $n; - } - if (!$db) { - $db = $this->DB(); - if (!$db) { - return false; - } - } - return $db->nameQuote.$n.$db->nameQuote; - } - //------------------------------------------------------------ Public functions below function Load($where=null,$bindarr=false, $lock = false) @@ -983,7 +969,7 @@ class ADODB_Active_Record { } $t = $db->MetaType($fld->type); - $arr[$name] = $this->doquote($db,$val,$t); + $arr[$name] = $this->doQuote($db, $val, $t); $valarr[] = $val; } |
