]> git.nbdom.net Git - nb.git/commitdiff
lib/postgres/country.sql
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Sun, 29 Jul 2018 15:56:56 +0000 (16:56 +0100)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Sun, 29 Jul 2018 15:56:56 +0000 (16:56 +0100)
lib/php/db/table.php
lib/postgres/country.sql
www/dbq/dbq.php

index 95d21b6ebce920e02eab5507420dabefc439d28e..3330e58e1497ac881ea9a2ebb168511d0c1c3a81 100644 (file)
@@ -33,7 +33,8 @@ Class Table extends nb {
        public $engine;
        public $created;
        public static $is_admin = true;
-       public $key_preff = '_key_';
+# NB 28.07.18  public $key_preff = '_key_';
+       public $key_preff = '';
 
        public $fields = [];
        public $fields_only = []; # filter for rows
@@ -1837,7 +1838,7 @@ Class Table extends nb {
 
                        if ($field->extras) continue;
 
-                       $value = $post[$this->ppreff().$name];
+# NB 28.07.18                  $value = $post[$this->ppreff().$name];
 
                        if ($field->key) {
                                $keys[] = $name;
@@ -1847,21 +1848,21 @@ Class Table extends nb {
                                        continue;
                                }
 
-# NB 12.12.17         $_value = isset($post[$this->key_preff.$name]) ? $post[$this->key_preff.$name] : null;
-
-                               if (isset($post[$this->key_preff.$name])) {
+# NB 28.07.18                          if (isset($post[$this->key_preff.$name])) {
                                        $fields[] = $name;
                                        $fields_values[] = $post[$this->key_preff.$name];
                                        $keys_values[] = $post[$this->key_preff.$name];
 
-                               } else {
-                                       $keys_values[] = $value;
-                               }
+# NB 28.07.18                          } else {
+# NB 28.07.18                                  $keys_values[] = $value;
+# NB 28.07.18                          }
 
-                       } else {
+# NB 28.07.18                  } else {
+                       } elseif(isset($post[$this->key_preff.$name])) {
 
                                $fields[] = $name;
-                               $fields_values[] = $value;
+# NB 28.07.18                          $fields_values[] = $value;
+                               $fields_values[] = $post[$this->key_preff.$name];
 
                        }
 
@@ -1891,6 +1892,7 @@ Class Table extends nb {
                        .' WHERE ' . join(' AND ',$this->ar_map('"$a=:key_$a"',$keys))
                ;
                #$info['sql'] = $sql;
+               #bye($sql);
                $info = [ 'sql' => $sql ] + $info;
 
                if ($bindParam and !($query = $this->db()->conn->prepare($sql))) {
index b44feb04e638f5d6e9b042748a300db7544083fd..d2f6ab24eb356528555d49f30c7ec071522be418 100644 (file)
@@ -34,7 +34,7 @@ CREATE TABLE IF NOT EXISTS country (
   currency_name varchar(20),
   phone varchar(30),
   zip_format varchar(60),
-  zip_regexp varchar(150),
+  zip_regexp varchar(300),
   languages varchar(100),
   geoid bigint,
   neighbours varchar(60),
index e880f08b5af2764771571b3750dc5c8414c57b2a..8f36157f13342d5af09fd6f9c887d6ab28bd1ddc 100644 (file)
@@ -1349,19 +1349,19 @@ EOF;
 
                } elseif ($action == 'insert') {
                        $this->deniedUnless($this->perm >= self::WRITE);
-                       if (!$this->table->insert($_POST,$info)) $this->error('insert: '.print_r($info,true));
+                       if (!$this->table->insert(empty($_POST) ? $_GET : $_POST,$info)) $this->error('insert: '.print_r($info,true));
                        header('Location: '.$this->table->base.'/');
                        $this->page($info);
 
                } elseif ($action == 'update') {
                        $this->deniedUnless($this->perm >= self::WRITE);
-                       if (!$this->table->update($_POST,$info)) $this->error('update: '.print_r($info,true));
+                       if (!$this->table->update(empty($_POST) ? $_GET : $_POST,$info)) $this->error('update: '.print_r($info,true));
                        $this->redirect_if_no_referer($this->table->base.'/');
                        $this->page($info);
 
                } elseif ($action == 'replace') {
                        $this->deniedUnless($this->perm >= self::WRITE);
-                       if (!$this->table->replace($_POST,$info)) $this->error('replace: '.print_r($info,true));
+                       if (!$this->table->replace(empty($_POST) ? $_GET : $_POST,$info)) $this->error('replace: '.print_r($info,true));
                        $this->redirect_if_no_referer($this->table->base.'/');
                        $this->page($info);