From 3fc28c0142bf8ab4e2cfae44931e2a51aadc4d51 Mon Sep 17 00:00:00 2001
From: mcramer <m.cramer@pixcept.de>
Date: Mon, 25 Feb 2013 13:51:37 -0500
Subject: [PATCH] - Added: remoting queries with a lot of results (e.g. email addresses or alias domains or dns rr) lead to non-functioning soap requests - added '#OFFSET#' AND '#LIMIT#' handling to the query - added automatic 'WHERE 1' if an empty array was given as query example: $result = $api->sites_web_domain_get('type' => 'vhost', '#OFFSET#' => 25, '#LIMIT#' => 50); to get the websites 26 to 75
---
interface/lib/classes/remoting_lib.inc.php | 10 ++++++++--
1 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/interface/lib/classes/remoting_lib.inc.php b/interface/lib/classes/remoting_lib.inc.php
index c636518..8a32883 100644
--- a/interface/lib/classes/remoting_lib.inc.php
+++ b/interface/lib/classes/remoting_lib.inc.php
@@ -802,18 +802,24 @@
$sql = "SELECT * FROM ".$escape.$this->formDef['db_table'].$escape." WHERE ".$this->formDef['db_table_idx']." = ".$primary_id;
return $app->db->queryOneRecord($sql);
} elseif (@is_array($primary_id)) {
- $sql_where = '';
+ $sql_offset = 0;
+ $sql_limit = 0;
+ $sql_where = '';
foreach($primary_id as $key => $val) {
$key = $app->db->quote($key);
$val = $app->db->quote($val);
- if(stristr($val,'%')) {
+ if($key == '#OFFSET#') $sql_offset = $app->functions->intval($val);
+ elseif($key == '#LIMIT#') $sql_limit = $app->functions->intval($val);
+ elseif(stristr($val,'%')) {
$sql_where .= "$key like '$val' AND ";
} else {
$sql_where .= "$key = '$val' AND ";
}
}
$sql_where = substr($sql_where,0,-5);
+ if($sql_where == '') $sql_where = '1';
$sql = "SELECT * FROM ".$escape.$this->formDef['db_table'].$escape." WHERE ".$sql_where;
+ if($sql_offset >= 0 && $sql_limit > 0) $sql .= ' LIMIT ' . $sql_offset . ',' . $sql_limit;
return $app->db->queryAllRecords($sql);
} else {
$this->errorMessage = 'The ID must be either an integer or an array.';
--
Gitblit v1.9.1