From: Nicolas Boisselier Date: Tue, 3 Nov 2015 00:41:40 +0000 (+0100) Subject: yaml X-Git-Url: https://git.nbdom.net/?a=commitdiff_plain;h=9843b8c901ec87329d78e773ff9f66e80e2eccf7;p=nb.git yaml --- diff --git a/lib/php/db.php b/lib/php/db.php index 4d36eb96..5d61913d 100644 --- a/lib/php/db.php +++ b/lib/php/db.php @@ -163,6 +163,7 @@ class db extends nb { } /* + */ function query2a($sql) { $r = $this->conn->query($sql,PDO::FETCH_COLUMN); return $r ? $r->fetch() : $r; @@ -181,7 +182,6 @@ class db extends nb { return $this->conn->query($sql,PDO::FETCH_ASSOC); } - */ function quote($v) { return $this->conn->quote($v); } diff --git a/lib/php/db/table.php b/lib/php/db/table.php index 686f6a0b..3be38eab 100644 --- a/lib/php/db/table.php +++ b/lib/php/db/table.php @@ -613,15 +613,18 @@ 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 { - $query = $this->db->conn->query("SELECT count(*)".preg_replace('/^SELECT .*?FROM/',' FROM',$sql)); - #$query = $this->db->conn->query("SELECT count(*) FROM ($sql) count"); + $sql_count = preg_replace('/^SELECT .*?FROM/s','SELECT count(*) FROM',$sql); + $sql_count = preg_replace('/ (ORDER|LIMIT) .*?$/s','',$sql_count); + $query = $this->db->conn->query($sql_count); } + if (!$query) { $err = $this->db->conn->errorInfo(); $err[] = $sql; err(join(' | ',$err)); return $err[0]; } + $tot = $query->fetch(PDO::FETCH_COLUMN); $opt['tot'] = $tot; #if (!$tot) return;