From: Nicolas Boisselier Date: Wed, 10 Jan 2018 03:32:38 +0000 (+0000) Subject: lib/php/db.php X-Git-Url: https://git.nbdom.net/?a=commitdiff_plain;h=1febd25dc6cb324d8cf23b5d5ec2335c207d8011;p=nb.git lib/php/db.php --- diff --git a/lib/php/db.php b/lib/php/db.php index 17b33b05..a7135acb 100644 --- a/lib/php/db.php +++ b/lib/php/db.php @@ -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) { diff --git a/lib/php/db/field.php b/lib/php/db/field.php index 4dfa67a9..28655d34 100644 --- a/lib/php/db/field.php +++ b/lib/php/db/field.php @@ -1,14 +1,5 @@ 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; diff --git a/lib/php/db/table.php b/lib/php/db/table.php index 7bd421b9..22f8c258 100644 --- a/lib/php/db/table.php +++ b/lib/php/db/table.php @@ -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(); diff --git a/lib/php/db/types/sqlite.php b/lib/php/db/types/sqlite.php index 5780a44e..c6a72e63 100644 --- a/lib/php/db/types/sqlite.php +++ b/lib/php/db/types/sqlite.php @@ -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 diff --git a/lib/php/nb.php b/lib/php/nb.php index f860724a..3c804d54 100644 --- a/lib/php/nb.php +++ b/lib/php/nb.php @@ -777,7 +777,7 @@ class NB { } return $match; - return (bool)($not ? !$match : $match); +# NB 10.01.18 return (bool)($not ? !$match : $match); }