From 1f2ce8531ea3d9e3cb6380f282d7ee89bd559836 Mon Sep 17 00:00:00 2001 From: Nicolas Boisselier Date: Sun, 29 Jul 2018 16:56:56 +0100 Subject: [PATCH] lib/postgres/country.sql --- lib/php/db/table.php | 22 ++++++++++++---------- lib/postgres/country.sql | 2 +- www/dbq/dbq.php | 6 +++--- 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/lib/php/db/table.php b/lib/php/db/table.php index 95d21b6e..3330e58e 100644 --- a/lib/php/db/table.php +++ b/lib/php/db/table.php @@ -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))) { diff --git a/lib/postgres/country.sql b/lib/postgres/country.sql index b44feb04..d2f6ab24 100644 --- a/lib/postgres/country.sql +++ b/lib/postgres/country.sql @@ -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), diff --git a/www/dbq/dbq.php b/www/dbq/dbq.php index e880f08b..8f36157f 100644 --- a/www/dbq/dbq.php +++ b/www/dbq/dbq.php @@ -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); -- 2.47.3