mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-01-13 17:38:19 +01:00
Changed around the limit_query() function to be easier for developers to use
This commit is contained in:
parent
3f0af80b97
commit
fc49aa8594
@ -116,6 +116,8 @@ class db {
|
|||||||
{
|
{
|
||||||
global $phpgw_info;
|
global $phpgw_info;
|
||||||
|
|
||||||
|
echo '<b>Warning: limit() is no longer used, use limit_query()</b>';
|
||||||
|
|
||||||
if ($start == 0) {
|
if ($start == 0) {
|
||||||
$s = "limit " . $phpgw_info["user"]["preferences"]["common"]["maxmatchs"];
|
$s = "limit " . $phpgw_info["user"]["preferences"]["common"]["maxmatchs"];
|
||||||
} else {
|
} else {
|
||||||
@ -165,21 +167,37 @@ class db {
|
|||||||
return $this->Query_ID;
|
return $this->Query_ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
// public: perform a query with limited result set
|
// public: perform a query with limited result set
|
||||||
function limit_query($Query_String, $offset, $num_rows, $line = '', $file = '')
|
function limit_query($Query_String, $_offset, $line = '', $file = '')
|
||||||
{
|
{
|
||||||
global $phpgw_info;
|
global $phpgw_info;
|
||||||
|
|
||||||
if ($this->Debug)
|
if (is_array($_offset))
|
||||||
printf("Debug: limit_query = %s<br>offset=%d, num_rows=%d<br>\n", $Query_String, $offset, $num_rows);
|
{
|
||||||
|
list($offset,$num_rows) = $_offset;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$num_rows = $phpgw_info['user']['preferences']['common']['maxmatchs'];
|
||||||
|
$offset = $_offset;
|
||||||
|
}
|
||||||
|
|
||||||
if (!IsSet($num_rows) || $num_rows < 1)
|
if ($offset == 0)
|
||||||
$num_rows = $phpgw_info['user']['preferences']['common']['maxmatchs'];
|
{
|
||||||
|
$Query_String .= ' LIMIT ' . $num_rows;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$Query_String .= ' LIMIT ' . $offset . ',' . $num_rows;
|
||||||
|
}
|
||||||
|
|
||||||
$Query_String .= ' LIMIT ' . $offset . ',' . $num_rows;
|
if ($this->Debug)
|
||||||
|
{
|
||||||
|
printf("Debug: limit_query = %s<br>offset=%d, num_rows=%d<br>\n", $Query_String, $offset, $num_rows);
|
||||||
|
}
|
||||||
|
|
||||||
return $this->query($Query_String, $line, $file);
|
return $this->query($Query_String, $line, $file);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* public: walk result set */
|
/* public: walk result set */
|
||||||
function next_record() {
|
function next_record() {
|
||||||
|
@ -69,6 +69,8 @@ class db {
|
|||||||
{
|
{
|
||||||
global $phpgw_info;
|
global $phpgw_info;
|
||||||
|
|
||||||
|
echo '<b>Warning: limit() is no longer used, use limit_query()</b>';
|
||||||
|
|
||||||
if ($start == 0) {
|
if ($start == 0) {
|
||||||
$s = "limit " . $phpgw_info["user"]["preferences"]["common"]["maxmatchs"];
|
$s = "limit " . $phpgw_info["user"]["preferences"]["common"]["maxmatchs"];
|
||||||
} else {
|
} else {
|
||||||
@ -109,21 +111,37 @@ class db {
|
|||||||
return $this->Query_ID;
|
return $this->Query_ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
// public: perform a query with limited result set
|
// public: perform a query with limited result set
|
||||||
function limit_query($Query_String, $offset, $num_rows, $line = '', $file = '')
|
function limit_query($Query_String, $_offset, $line = '', $file = '')
|
||||||
{
|
{
|
||||||
global $phpgw_info;
|
global $phpgw_info;
|
||||||
|
|
||||||
if ($this->Debug)
|
if (is_array($_offset))
|
||||||
printf("Debug: limit_query = %s<br>offset=%d, num_rows=%d<br>\n", $Query_String, $offset, $num_rows);
|
{
|
||||||
|
list($offset,$num_rows) = $_offset;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$num_rows = $phpgw_info['user']['preferences']['common']['maxmatchs'];
|
||||||
|
$offset = $_offset;
|
||||||
|
}
|
||||||
|
|
||||||
if (!IsSet($num_rows) || $num_rows < 1)
|
if ($offset == 0)
|
||||||
$num_rows = $phpgw_info['user']['preferences']['common']['maxmatchs'];
|
{
|
||||||
|
$Query_String .= ' LIMIT ' . $num_rows;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$Query_String .= ' LIMIT ' . $num_rows . ',' . $offset;
|
||||||
|
}
|
||||||
|
|
||||||
$Query_String .= ' LIMIT ' . $offset . ',' . $num_rows;
|
if ($this->Debug)
|
||||||
|
{
|
||||||
|
printf("Debug: limit_query = %s<br>offset=%d, num_rows=%d<br>\n", $Query_String, $offset, $num_rows);
|
||||||
|
}
|
||||||
|
|
||||||
return $this->query($Query_String, $line, $file);
|
return $this->query($Query_String, $line, $file);
|
||||||
}
|
}
|
||||||
|
|
||||||
// public: discard the query result
|
// public: discard the query result
|
||||||
function free() {
|
function free() {
|
||||||
|
Loading…
Reference in New Issue
Block a user