]> git.nbdom.net Git - nb.git/commitdiff
sort and extras in db.yaml
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Wed, 16 Dec 2015 15:23:44 +0000 (15:23 +0000)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Wed, 16 Dec 2015 15:23:44 +0000 (15:23 +0000)
lib/php/db/table.php
lib/php/functions.php
lib/php/nb.php

index 3be38eab9ee5fcd91cacea391f55c0cabaf952ae..d07bb0cd65cfacf36da9a387a211ca7a8694941d 100644 (file)
@@ -613,8 +613,9 @@ FROM pg_catalog.pg_attribute a WHERE a.attrelid = (SELECT c.oid FROM pg_catalog.
     if ($this->db->type =='mysql') {
       $query = $this->db->conn->query('SELECT FOUND_ROWS()');
     } else {
-      $sql_count = preg_replace('/^SELECT .*?FROM/s','SELECT count(*) FROM',$sql);
+      $sql_count = $sql;
       $sql_count = preg_replace('/ (ORDER|LIMIT) .*?$/s','',$sql_count);
+      $sql_count = preg_replace('/^SELECT .*FROM/s','SELECT count(*) FROM (',$sql_count).') count';
       $query = $this->db->conn->query($sql_count);
     }
 
index bae7d64b0bdc24e13f6bf51dccf3fd695728d228..1103b57972a4d8490d58f92c3987b9b2fe83441e 100644 (file)
@@ -115,6 +115,7 @@ function debug($msg,$level=0) {
   if (preg_match('/ml/i',nb::get_header('Content-type'))) {
     echo '<pre class="debug">'
       .(@$_SERVER['HTTP_HOST'] ? htmlentities($msg) : $msg)
+# NB 16.12.15       .(@$_SERVER['HTTP_HOST'] ? htmlspecialchars($msg) : $msg)
     .'</pre>'.PHP_EOL;
 
   } else {
index babe986314f1d2fe2de6368076a4d133a7c81023..91fb341bb456846544a104e401666b6db007ea37 100644 (file)
@@ -87,12 +87,10 @@ class nb {
    * Return a client header
    */
   static function get_header($name,$value=null) {
-    $v = array_map(create_function('$a',
-      #'return $a;'
-      'return( preg_match("/^'.$name.':\s+(\S+)/i",$a,$m) ? $m[1] : null );'
-    ),headers_list());
-
-    return $v ? $v[0] : null;
+    foreach (headers_list() as $a) {
+      if ( preg_match("/^$name:\s+(.*)/i",$a,$m) ) return $m[1];
+    }
+    return null;
   }
 
 }