]> git.nbdom.net Git - nb.git/commitdiff
lib/php/db.php
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Mon, 4 Dec 2017 17:34:19 +0000 (17:34 +0000)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Mon, 4 Dec 2017 17:34:19 +0000 (17:34 +0000)
etc/profile.d/dbq.sh
lib/php/db.php
lib/php/db/table.php
lib/php/db/types/pgsql.php

index c3e39c6da60502690fadc20ccb048c52b435d80f..7c1f6b3015d3e194c2623e437938e6370443916c 100644 (file)
@@ -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
index fab714161f3a6a6cd7fed7e4d6a0fdf84def9330..a6222a369ca4eead698ce6ad87d879a982e65dfc 100644 (file)
@@ -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;
       }
 
     }
index e8592e337350769f245c92e4fb6a4d0a6b5800f9..4384d556600408cd902adedddad8dbe6939dd207 100644 (file)
@@ -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)) {
 
index 85b9fa08334fd1da8c0164fe1044403d69118a2e..c55b3d4a50ff91e35c0d724b87d0aef98ffd9021 100644 (file)
@@ -2,6 +2,7 @@
 $DB_TYPES['pgsql'] = array (
 'extra_where' => 'denorm',
 'regexp' => '~',
+'quote_name' => '"',
 
 'localFile' => array (getenv('HOME').'/.pgpass','^[^:]+:[^:]+:<D.NAME>:(?P<user>[^:]+):(?<password>[^:]+)'),