From: Nicolas Boisselier Date: Tue, 28 Jul 2015 15:27:28 +0000 (+0100) Subject: fix warning from php X-Git-Url: https://git.nbdom.net/?a=commitdiff_plain;h=04265654f3c44110074fa45fdff00ceb8dc68bb5;p=nb.git fix warning from php --- diff --git a/lib/php/db.php b/lib/php/db.php index 634931e7..25dda23d 100644 --- a/lib/php/db.php +++ b/lib/php/db.php @@ -50,7 +50,7 @@ class db { try { - $this->conn = new PDO($this->pdo,$this->username,$this->password,$options); + $this->conn = new PDO($this->pdo,$this->username,$this->password,$this->options); if (isset($this->pdo_error)) $this->conn->setAttribute(PDO::ATTR_ERRMODE, $this->pdo_error); } catch (PDOException $e) { @@ -342,7 +342,7 @@ EOF; function sql_name($value) { if (preg_match('/^\w+$/',$value)) return $value; - if ($this->db->type == 'mysql') return '`'.$value.'`'; + if ($this->type == 'mysql') return '`'.$value.'`'; return '"'.$value.'"'; } diff --git a/lib/php/db/field.php b/lib/php/db/field.php index 7cca1198..4b7cb09e 100644 --- a/lib/php/db/field.php +++ b/lib/php/db/field.php @@ -48,13 +48,16 @@ class field { function quote($value,$force_quote=false) { + if ($value === null) return 'NULL'; if ($force_quote or !$this->numeric()) { if (($db = $this->db()) === null) return "'".preg_replace("/'/","\\'",$value)."'"; return $db->quote($value); + } else { if (strcmp($value,'') == 0) $value = 'NULL'; + #if ($value === null) $value = 'NULL'; } return $value; @@ -114,7 +117,7 @@ class field { function pdo_type() { if (func_get_args()>0 and func_get_arg(0) === null) return PDO::PARAM_NULL; - if ($this->numeric) return PDO::PARAM_INT; + if ($this->numeric()) return PDO::PARAM_INT; if (strpos($this->type,'bool') !== false ) return PDO::PARAM_BOOL; if (strpos($this->type,'blob') !== false ) return PDO::PARAM_LOB; # not a bug LOB return PDO::PARAM_STR; diff --git a/lib/php/db/table.php b/lib/php/db/table.php index 85939380..009cd9ed 100644 --- a/lib/php/db/table.php +++ b/lib/php/db/table.php @@ -203,7 +203,8 @@ FROM pg_catalog.pg_attribute a WHERE a.attrelid = (SELECT c.oid FROM pg_catalog. if (empty($keys)) $keys = $others; foreach ($keys as $name => $field) { - if (isset($values[$name]) and strcmp($values[$name],'')!=0) + #if (isset($values[$name]) and strcmp($values[$name],'')!=0) + if (isset($values[$name])) $url[] = $name . '=' .urlencode($values[$name]) ; } @@ -274,8 +275,6 @@ FROM pg_catalog.pg_attribute a WHERE a.attrelid = (SELECT c.oid FROM pg_catalog. .''.PHP_EOL .''.PHP_EOL; - $this->row = $row; - return $this; } function debug($msg,$level=0) { return debug($msg,$level); } @@ -571,7 +570,7 @@ FROM pg_catalog.pg_attribute a WHERE a.attrelid = (SELECT c.oid FROM pg_catalog. // Select // $sql = "SELECT *" . $this->select_extras(); - $sql .= " FROM $this->name".$this->where_criterias($this->db->p(),$this->db->p('op')); + $sql .= " FROM ".$this->sql_name().$this->where_criterias($this->db->p(),$this->db->p('op')); $this->sql = $sql; $this->debug($sql,1); @@ -784,6 +783,7 @@ FROM pg_catalog.pg_attribute a WHERE a.attrelid = (SELECT c.oid FROM pg_catalog. function rows_end_table($opt=array()) { #$html = ''.PHP_EOL; + $html = ''; if (!empty($opt['count'])) $html .= ''#''.PHP_EOL .'' @@ -941,6 +941,7 @@ FROM pg_catalog.pg_attribute a WHERE a.attrelid = (SELECT c.oid FROM pg_catalog. } $sql = 'DELETE FROM ' . $this->sql_name() . $where; + bye($sql); return $this->db->exec($sql); }