]> git.nbdom.net Git - nb.git/commitdiff
update not working, using replace
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Mon, 19 Dec 2016 16:14:32 +0000 (16:14 +0000)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Mon, 19 Dec 2016 16:14:32 +0000 (16:14 +0000)
lib/php/db.php
lib/php/db/table.php
www/dbq/dbq.php

index 7aabfe23d0f9c81bd19c6a8cb829bc234e0d2cfc..3f614c1bbc360d27a7abb0b154e60c98ba3cc62b 100644 (file)
@@ -298,7 +298,7 @@ class Db extends nb {
     }
 
     #try {
-    foreach ($this->sql_pre() as $s) { $this->conn->exec($s); }
+    #foreach ($this->sql_pre() as $s) { $this->conn->exec($s); }
     $this->method('connect');
     #} catch (PDOException $e) {
     #return false;
@@ -309,6 +309,9 @@ class Db extends nb {
 
        public function disconnect() {
     if (empty($this->conn)) return null;
+# NB 19.12.16     foreach ((array)$this->method('sql.post') as $s) {
+# NB 19.12.16       $r = $this->conn->exec($s);
+# NB 19.12.16     }
     $this->method('disconnect');
 # NB 09.09.16     return $this->conn->close();
   }
index f9451f0c15858577619ccce5e50c33d155de5a86..188902bd91b85a6c4598b61944229c09e54afb8f 100644 (file)
@@ -1446,6 +1446,7 @@ Class Table extends nb {
     return $this->db()->exec($sql,$values);
     return $this->db()->exec($sql);
   }
+
   # dbq t=nb.mime_type a=table.update type=application/rss+xml name='RSS - Really Simple Syndication' ext=rss debug=2
   public function update($hvalues,&$info=[]) {
     if (empty($info['values'])) $info['values'] = [];
@@ -1479,9 +1480,11 @@ Class Table extends nb {
       }
 
     }
+
     $info['keys'] = array_combine($keys,$keys_values);
 
     if (empty($fields)) $this->bye("Missing keys!");
+
     if (empty($keys)) {
       $this->bye("Missing keys!");
       $keys = $fields;
@@ -1504,6 +1507,7 @@ Class Table extends nb {
       #debug("$name: ".$hvalues[$name]);
       $row = [ $name => $hvalues[$name] ];
       $this->db()->table_row_encrypt($this,$row);
+      #debug($this->db()->status());
       $field->bindParam($query,$row[$name],":$name");
     }
 
@@ -1513,7 +1517,7 @@ Class Table extends nb {
     }
 
     #return $sql;
-    #bye($sql);
+    #bye($info);
     if (self::p('debug')) {
       $this->debug($info,1);
       return false;
@@ -1525,8 +1529,9 @@ Class Table extends nb {
     }
 
     $info['rowCount'] = $query->rowCount();
+    #bye($this->db()->row("SELECT value FROM crypt WHERE id='zaza'"));
     #bye($info);
-    return true;
+    #return true;
     #debug($execute);
     return $query->rowCount();
 
index 50e09e250310e810fea82553c2a07f604972ef35..90fbbe2be9707e8675776a35cfd68d750eb4dc16 100644 (file)
@@ -518,15 +518,16 @@ table.rows th, table.rows td { border-color: '.$this->colors['body-border'].'; }
       $this->page($this,'table_html_edit');
 
     } elseif ($action == 'insert' and $this->perm >= self::WRITE) {
-      if (!$this->table->insert($_POST)) $this->error('insert');
+      if (!$this->table->insert($_POST,$info)) $this->error('insert: '.print_r($info,true));
       header('Location: '.$this->table->base);
 
     } elseif ($action == 'update' and $this->perm >= self::WRITE) {
-      if (!$this->table->update($_POST)) $this->error('update');
+    # NB 19.12.16: TODO NOT WORKING using replace 
+      if (!$this->table->replace($_POST,$info)) $this->error('update: '.print_r($info,true));
       header('Location: '.$this->table->base);
 
     } elseif ($action == 'rm' and $this->perm >= self::DELETE) {
-      if (!$this->table->delete($_POST)) $this->error('rm');
+      if (!$this->table->delete($_POST,$info)) $this->error('rm: '.print_r($info,true));
       header('Location: '.$this->table->base);
 
 
@@ -535,7 +536,7 @@ table.rows th, table.rows td { border-color: '.$this->colors['body-border'].'; }
 
     }
 
-    return false;
+    return true;
   }
 
 }