'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) {
<?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;
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;
} else {
if (strcmp($value,'') == 0) $value = 'NULL';
- #if ($value === null) $value = 'NULL';
}
return $value;
}
$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();
$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
}
return $match;
- return (bool)($not ? !$match : $match);
+# NB 10.01.18 return (bool)($not ? !$match : $match);
}