]> git.nbdom.net Git - nb.git/commitdiff
www/dbq/dbq.php
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Sun, 7 Jan 2018 05:58:28 +0000 (05:58 +0000)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Sun, 7 Jan 2018 05:58:28 +0000 (05:58 +0000)
lib/php/db.php
lib/php/db/table.php
lib/php/db/types/pgsql.php

index 4fd3535f96eded261818d34c40aa9c3f6b511ec9..5d706db4ea7a198e5cfd303c082288ca1b022aaf 100644 (file)
@@ -762,6 +762,12 @@ class Db extends nb {
       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;
     }
 
index 6e1f819f944fcc3dc10af8094940b1fe79d02182..96aae863e107d892426a9b32996918c5be0a9eeb 100644 (file)
@@ -771,7 +771,7 @@ Class Table extends nb {
         $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);
@@ -797,17 +797,13 @@ Class Table extends nb {
                        $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)";
index 67166255ccbae7536363df4a9079760fd48e9f39..0837a2e03f9e118f5a13c6c31808eadf3d4a82e3 100644 (file)
@@ -13,27 +13,11 @@ $DB_TYPES['pgsql'] = array (
   $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>[^:]+)'),