mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-22 23:00:56 +01:00
Tidy up function for limit_query.
This commit is contained in:
parent
030232dfc3
commit
f58b8aa55e
@ -170,15 +170,6 @@ class db {
|
|||||||
{
|
{
|
||||||
global $phpgw_info;
|
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)
|
if ($this->Debug)
|
||||||
printf("Debug: limit_query = %s<br>offset=%d, num_rows=%d<br>\n", $Query_String, $offset, $num_rows);
|
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;
|
$Query_String .= ' LIMIT ' . $offset . ',' . $num_rows;
|
||||||
|
|
||||||
$this->Query_ID = @mysql_query($Query_String, $this->Link_ID);
|
return $this->query($Query_String, $line, $file);
|
||||||
$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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* public: walk result set */
|
/* public: walk result set */
|
||||||
|
@ -105,6 +105,22 @@ class db {
|
|||||||
return $this->Query_ID;
|
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
|
// public: discard the query result
|
||||||
function free() {
|
function free() {
|
||||||
@pg_freeresult($this->Query_ID);
|
@pg_freeresult($this->Query_ID);
|
||||||
@ -355,4 +371,4 @@ class db {
|
|||||||
$this->connect();
|
$this->connect();
|
||||||
//return $return;
|
//return $return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user