* A class that implements the DB interface for Postgres
* Note: This class uses ADODB and returns RecordSets.
*
- * $Id: Postgres.php,v 1.109 2003/05/18 11:53:28 chriskl Exp $
+ * $Id: Postgres.php,v 1.110 2003/05/18 12:48:11 chriskl Exp $
*/
// @@@ THOUGHT: What about inherits? ie. use of ONLY???
return $rs;
}
+ /**
+ * Finds the number of rows that would be returned by a
+ * query.
+ * @param $query The SQL query
+ * @param $count The count query
+ * @return The count of rows
+ * @return -1 error
+ */
+ function browseSQLCount($query, $count) {
+ // Count the number of rows
+ $rs = $this->selectSet($query);
+ if (!is_object($rs)) {
+ return -1;
+ }
+
+ return $rs->recordCount();
+ }
+
/**
* Returns a recordset of all columns in a query. Supports paging.
* @param $query The SQL SELECT query.
if ($status != 0) return -1;
// Count the number of rows
- $total = $this->selectField($count, 'total');
+ $total = $this->browseSQLCount($query, $count);
if ($total < 0) {
$this->rollbackTransaction();
return -2;
$this->conn->setFetchMode(ADODB_FETCH_NUM);
// Actually retrieve the rows, with offset and limit
- // @@@@@@@@@@@@@@ THIS NEXT LINE ONLY WORKS IN POSTGRESQL 7.2+ @@@@@@@@@@@@@@@@@
- //$sql = "SELECT * FROM ($query) LIMIT {$page_size} OFFSET " . ($page - 1) * $page_size);
$rs = $this->selectSet("{$query} LIMIT {$page_size} OFFSET " . ($page - 1) * $page_size);
$status = $this->endTransaction();
* A class that implements the DB interface for Postgres
* Note: This class uses ADODB and returns RecordSets.
*
- * $Id: Postgres71.php,v 1.33 2003/05/17 15:51:37 chriskl Exp $
+ * $Id: Postgres71.php,v 1.34 2003/05/18 12:48:11 chriskl Exp $
*/
// @@@ THOUGHT: What about inherits? ie. use of ONLY???
}
// Table functions
-
+
+ /**
+ * Finds the number of rows that would be returned by a
+ * query.
+ * @param $query The SQL query
+ * @param $count The count query
+ * @return The count of rows
+ * @return -1 error
+ */
+ function browseSQLCount($query, $count) {
+ return $this->selectField($count, 'total');
+ }
+
/**
* Retrieve the attribute definition of a table
* @param $table The name of the table