]> git.nbdom.net Git - nb.git/commitdiff
lib/php/db.php
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Mon, 4 Dec 2017 18:12:28 +0000 (18:12 +0000)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Mon, 4 Dec 2017 18:12:28 +0000 (18:12 +0000)
lib/php/db.php
lib/php/db/field.php
lib/php/db/types/pgsql.php

index a6222a369ca4eead698ce6ad87d879a982e65dfc..b65d3caa1cc97f9cba7e2e17fff9eb5d7e1f1e49 100644 (file)
@@ -1016,6 +1016,7 @@ class Db extends nb {
     }
 
       #bye($this->db()->type);
+    if ($type_from == 'mysql') $views = []; # Mysql store sql create view in mysql format wich only works with mysql
     foreach (array_merge($tables,$views) as $t) {
 
       # DROP / CREATE
index 9531690746c36b061373c8e9ab7697defc6e6427..4424078cac07427626a68bcb47b127ea61fb21da 100644 (file)
@@ -215,7 +215,9 @@ class field extends nb {
         if (strpos($this->type,'date') !== false) return 'NULL';
       }
 
-      if (!($db = $this->db())) return "'".preg_replace("/'/","''",$value)."'";
+      if (!($db = $this->db())) return "'".str_replace("'","''",$value)."'";
+
+      if ($fct=$db->conf_type('quote_field')) return $fct($value);
       return $db->quote($value);
 
     } else {
index ff74038b7f5cb3604fbc7f508f830542a742b2e6..703df8d9003856c3da565e6fd77d7db88c9b544c 100644 (file)
@@ -2,13 +2,19 @@
 $DB_TYPES['pgsql'] = array (
 'extra_where' => 'denorm',
 'regexp' => '~',
-# NB 04.12.17 'quote_name' => '"',
+# NB 04.12.17: Overwrite db->quote because of bugs with INSERT INTO 
+# NB 04.12.17 'quote_name' => "'",
 # NB 04.12.17 'quote' => function($str) {
 # NB 04.12.17   global $DB_TYPES;
 # NB 04.12.17   $chr = $DB_TYPES['pgsql']['quote_name'];
 # NB 04.12.17   str_replace($chr,$chr.$chr,$str);
 # NB 04.12.17   return $chr . $str . $chr;
 # NB 04.12.17 },
+'quote_field' => function($str) {
+  $chr = "'";
+  $str = str_replace($chr,$chr.$chr,$str);
+  return $chr . $str . $chr;
+},
 
 'localFile' => array (getenv('HOME').'/.pgpass','^[^:]+:[^:]+:<D.NAME>:(?P<user>[^:]+):(?<password>[^:]+)'),