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);
}
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 {
* 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;
}
}