From 6e265cc054ea3dd5c10834fcac228497e313ce70 Mon Sep 17 00:00:00 2001 From: Nicolas Boisselier Date: Mon, 4 Dec 2017 17:34:19 +0000 Subject: [PATCH] lib/php/db.php --- etc/profile.d/dbq.sh | 4 ---- lib/php/db.php | 6 ++++-- lib/php/db/table.php | 12 ++++++++++++ lib/php/db/types/pgsql.php | 1 + 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/etc/profile.d/dbq.sh b/etc/profile.d/dbq.sh index c3e39c6d..7c1f6b30 100644 --- a/etc/profile.d/dbq.sh +++ b/etc/profile.d/dbq.sh @@ -12,10 +12,6 @@ dbq2pgsql() { dbq f=txt a=db.dump db.type=pgsql $@ } -dbq_data_src() { - eval $(dbq t=data_src header=0 format=csv rows_fields=src name=$1) -} - dbq_template() { local t=$1 shift diff --git a/lib/php/db.php b/lib/php/db.php index fab71416..a6222a36 100644 --- a/lib/php/db.php +++ b/lib/php/db.php @@ -999,6 +999,7 @@ class Db extends nb { # Specific function $row_opt = [ 'parser' => false, + 'db_type_from' => $type_from, ]; if ($fct = $this->conf_type('table.sql.create')) { $row_opt['fct'] = $fct; @@ -1044,9 +1045,10 @@ class Db extends nb { # INSERT if ($insert and $t->type == 'table') { - if ($type_from) $this->type = $type_from; +# NB 04.12.17: Use instead "cleaner" option db_type_from +# NB 04.12.17 if ($type_from) $this->type = $type_from; $t->rows($row_opt); - if ($type_to) $this->type = $type_to; +# NB 04.12.17 if ($type_to) $this->type = $type_to; } } diff --git a/lib/php/db/table.php b/lib/php/db/table.php index e8592e33..4384d556 100644 --- a/lib/php/db/table.php +++ b/lib/php/db/table.php @@ -1005,6 +1005,14 @@ Class Table extends nb { public function rows(&$opt=[],$opt_by_val=null) { $opt['TABLE'] = $this; + # + # Db type change + # + $db_type = $this->db()->type; + if (!empty($opt['db_type_from'])) { + $this->db()->type = $opt['db_type_from']; + } + # # Fields # @@ -1104,6 +1112,10 @@ Class Table extends nb { # Parser on/off (default: on) if (!isset($opt['parser'])) $opt['parser'] = true; + if (!empty($opt['db_type_from'])) { + $this->db()->type = $db_type; + } + $count = 0; while ($row = $st->fetch(PDO::FETCH_ASSOC, PDO::FETCH_ORI_NEXT)) { diff --git a/lib/php/db/types/pgsql.php b/lib/php/db/types/pgsql.php index 85b9fa08..c55b3d4a 100644 --- a/lib/php/db/types/pgsql.php +++ b/lib/php/db/types/pgsql.php @@ -2,6 +2,7 @@ $DB_TYPES['pgsql'] = array ( 'extra_where' => 'denorm', 'regexp' => '~', +'quote_name' => '"', 'localFile' => array (getenv('HOME').'/.pgpass','^[^:]+:[^:]+::(?P[^:]+):(?[^:]+)'), -- 2.47.3