if (empty($params['name'])) $dbs[$db]['name'] = $db;
if (empty($params['id'])) $dbs[$db]['id'] = $db;
+ # Ignore incomplete
+ if (empty($params['type'])) {
+ unset($dbs[$db]);
+ continue;
+ }
+
foreach ($default as $k=>$v) if (!isset($params[$k])) $dbs[$db][$k] = $v;
}
$v = $this->db()->quote($v);
if (preg_match('/[_%]/',$v)) {
$match = 'like';
- $equal = ' '.($not ? 'NOT ' : '').'LIKE ';
+# NB 07.01.18 $equal = ' '.($not ? 'NOT ' : '').'LIKE ';
$equal = ' '.($not ? 'NOT ' : '').$this->db()->like_nocase().' ';
} else {
$equal = ($not ? '<> ' : $equal);
$name = $field->sql_name();
if (!preg_match('/^(char|varchar|text|blog)/i',$field->type)) $name = $field->sql_name_cast_text();
-# NB 04.01.18 if (preg_match("/(LIKE|$regexp) ..$/","$equal$v") and $field->null) {
-#bye("$equal$v");
- #if (preg_match("/(LIKE|$regexp) ..$/","$equal$v")) {
-# NB 07.01.18 if (preg_match("/^(LIKE|$regexp)$/",trim($equal))) {
- if ($match) {
- if ($field->null) $k = 'COALESCE('.$name.','.$this->db()->quote('').")";
-
- } elseif ($field->extras) {
+ if ($field->extras) {
$k = $this->extras[$k]->sql_name();
# NB 04.01.18 } elseif ($field->numeric() and $field->null) {
+ } elseif ($match) {
+ if ($field->null) $k = 'COALESCE('.$name.','.$this->db()->quote('').")";
+
} elseif ($field->numeric()) {
$name = $field->sql_name();
if ($field->null) $k = 'COALESCE('.$name.",0)";
$sql .= ' SET ' . join(',',$table->ar_map('"$a=:$a"',array_keys($others)));
#$info['debug'] = [$keys,$others];
},
+'like_nocase' => 'ILIKE',
+'cast_text' => function($name) { return "$name::text"; },
'extra_where' => 'denorm',
'regexp' => '~',
-# 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;
-},
-
-'cast_text' => function($name) {
- return "$name::text";
-},
-
-'like_nocase' => 'ILIKE',
+'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>[^:]+)'),