Tidy up function for limit_query.

This commit is contained in:
mdean 2001-07-01 17:04:42 +00:00
parent 030232dfc3
commit f58b8aa55e
2 changed files with 18 additions and 18 deletions

View File

@ -170,15 +170,6 @@ class db {
{
global $phpgw_info;
if ($Query_String == '')
return 0;
if (!$this->connect())
return 0; // we already complained in connect() about that.
if ($this->Query_ID)
$this->free();
if ($this->Debug)
printf("Debug: limit_query = %s<br>offset=%d, num_rows=%d<br>\n", $Query_String, $offset, $num_rows);
@ -187,14 +178,7 @@ class db {
$Query_String .= ' LIMIT ' . $offset . ',' . $num_rows;
$this->Query_ID = @mysql_query($Query_String, $this->Link_ID);
$this->Row = 0;
$this->Errno = mysql_errno();
$this->Error = mysql_error();
if (!$this->Query_ID)
$this->halt('Invalid SQL: ' . $Query_String, $line, $file);
return $this->Query_ID;
return $this->query($Query_String, $line, $file);
}
/* public: walk result set */

View File

@ -105,6 +105,22 @@ class db {
return $this->Query_ID;
}
// public: perform a query with limited result set
function limit_query($Query_String, $offset, $num_rows, $line = '', $file = '')
{
global $phpgw_info;
if ($this->Debug)
printf("Debug: limit_query = %s<br>offset=%d, num_rows=%d<br>\n", $Query_String, $offset, $num_rows);
if (!IsSet($num_rows) || $num_rows < 1)
$num_rows = $phpgw_info['user']['preferences']['common']['maxmatchs'];
$Query_String .= ' LIMIT ' . $offset . ',' . $num_rows;
return $this->query($Query_String, $line, $file);
}
// public: discard the query result
function free() {
@pg_freeresult($this->Query_ID);
@ -355,4 +371,4 @@ class db {
$this->connect();
//return $return;
}
}
}