mcramer
2013-02-25 3fc28c0142bf8ab4e2cfae44931e2a51aadc4d51
- 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

1 files modified
10 ■■■■ changed files
interface/lib/classes/remoting_lib.inc.php 10 ●●●● patch | view | raw | blame | history
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.';