]> git.nbdom.net Git - nb.git/commitdiff
lib/php/db.php
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Wed, 10 Jan 2018 03:32:38 +0000 (03:32 +0000)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Wed, 10 Jan 2018 03:32:38 +0000 (03:32 +0000)
lib/php/db.php
lib/php/db/field.php
lib/php/db/table.php
lib/php/db/types/sqlite.php
lib/php/nb.php

index 17b33b05577134e4a9234f7d3d83736ee37dd0cf..a7135acb635b43c24e5e0443745e6025122fadfa 100644 (file)
@@ -1041,9 +1041,10 @@ class Db extends nb {
       'format' => 'sql',
       'db_type_from' => $type_from,
     ];
-    if ($fct = $this->conf_type('table.sql.create')) {
-      $row_opt['fct'] = $fct;
-    }
+    # NB 10.01.18: Just create problems ! should be used ony for CREATE sql 
+# NB 10.01.18     if ($fct = $this->conf_type('table.sql.create')) {
+# NB 10.01.18       $row_opt['fct'] = $fct;
+# NB 10.01.18     }
 
     # SQL_PRE
     $i = 0; foreach ($this->sql_pre() as $s) {
index 4dfa67a9c743ec99c1ed35a6a7bf1a9f13bf94ce..28655d348b451758b3496ae1e8d1299d566b6c98 100644 (file)
@@ -1,14 +1,5 @@
 <?php
 require_once(realpath(dirname(__FILE__).'/../nb.php'));
-/*
-$DB_FIELD_TYPES = array(
- 'bool' => PDO::PARAM_BOOL,
- #'null' => PDO::PARAM_NULL,
- 'int' => PDO::PARAM_INT,
- 'str' => PDO::PARAM_STR,
- 'blob' => PDO::PARAM_LOB,
-);
-*/
 class field extends nb {
   private $table;
   public $name;
@@ -57,6 +48,10 @@ class field extends nb {
     return $this->autoincrement;
   }
 
+  public function text() {
+               return (bool)(preg_match('/^(char|varying|varchar|text|blog)/i',$this->type));
+       }
+
   public function string() {
     if ($this->numeric()) return false;
     if (strpos($this->type,'bool') !== false) return false;
@@ -240,7 +235,6 @@ class field extends nb {
     } else {
 
       if (strcmp($value,'') == 0) $value = 'NULL';
-      #if ($value === null) $value = 'NULL';
     }
 
     return $value;
index 7bd421b9282c4f9e16271d766eda18da5c74aeb6..22f8c25895166cfaddb57e46d0edb4c7caa8c07d 100644 (file)
@@ -805,7 +805,7 @@ Class Table extends nb {
       }
 
                        $name = $field->sql_name();
-                       if (!preg_match('/^(char|varchar|text|blog)/i',$field->type)) $name = $field->sql_name_cast_text();
+                       if (!$field->text()) $name = $field->sql_name_cast_text();
 
       if ($field->extras) {
         $k = $this->extras[$k]->sql_name();
index 5780a44eb4bde31e32ba9129473dfc93e9b3a796..c6a72e63c6ab8b782f7d78dc66665502af5f2e5a 100644 (file)
@@ -158,7 +158,7 @@ $DB_TYPES['sqlite'] = array (
   $r = [
     '/::\w+(\b|\s)/' => '$1', # pgsql cast;
     '/"([\w_]+)"\(/' => '$1(', # pgsql function quoted;
-    "/'([\w_]+\(.*?\))'/" => '$1', # pgsql function quoted;
+    "/'([\w_]+\([^\w-].*?\))'/" => '$1', # pgsql function quoted;
     "/now\(\)/i" => 'CURRENT_TIMESTAMP', # pgsql function quoted;
     '/left\((.*?),\s*(\d+)\s*\)/i' => 'SUBSTR($1,0,$2)', # function left to substr
     '/right\((.*?),\s*(\d+)\s*\)/i' => 'SUBSTR($1,$2,LENGTH($1))', # function right to substr
index f860724a0af5ea03d7392cc08e2dd42b1f6f0234..3c804d54956dc0ad80c718d8b7af64a6ed730235 100644 (file)
@@ -777,7 +777,7 @@ class NB {
                }
 
                return $match;
-               return (bool)($not ? !$match : $match);
+# NB 10.01.18          return (bool)($not ? !$match : $match);
 
        }