]> git.nbdom.net Git - nb.git/commitdiff
fix warning from php
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Tue, 28 Jul 2015 15:27:28 +0000 (16:27 +0100)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Tue, 28 Jul 2015 15:27:28 +0000 (16:27 +0100)
lib/php/db.php
lib/php/db/field.php
lib/php/db/table.php

index 634931e782ee747d0c836a0d361cdd1cbdacd89e..25dda23da58c179fa48e7577df815b355aa59eb6 100644 (file)
@@ -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.'"';
   }
 
index 7cca11986898e1c779500fc1eda9aeb6b2a20070..4b7cb09e53d0186e91c2549b5c5bf6e3881f05ec 100644 (file)
@@ -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;
index 85939380853dec81c790f806e23afe3557a39c69..009cd9edff137a25d49e3a63f0fe0f4ca9d55209 100644 (file)
@@ -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.
       .'</div>'.PHP_EOL
     .'</form>'.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 = '</tbody>'.PHP_EOL;
+    $html = '';
 
     if (!empty($opt['count'])) $html .= ''#'<tfoot>'.PHP_EOL
       .'<tr class="nav bottom">'
@@ -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);
   }