Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* API_DoQuery: http://www.quickbase.com/api-guide/index.html#do_query.html */
- public function do_query($queries = 0, $qid = 0, $qname = 0, $clist = 0, $slist = 0, $fmt = 'structured', $options = "")
- {
- if ($this->xml) {
- //A query in queries has the following items in this order:
- //field id, evaluator, criteria, and/or
- //The first element will not have an and/or
- $xml_packet = '<qdbapi>';
- $pos = 0;
- if ($queries) {
- $xml_packet .= '<query>';
- foreach ($queries as $query) {
- $criteria = "";
- if (isset($query['cx'])) {
- $xml_packet .= $query['cx']; //append any parentheses and boolean connectors
- } else {
- if ($pos > 0) {
- if(isset($query['ao'])) {
- $criteria .= $query['ao'];
- }
- }
- $criteria .= "{'" . $query['fid'] . "'." . $query['ev'] . ".'" . $query['cri'] . "'}";
- $xml_packet .= $criteria;
- }
- $pos++;
- }
- $xml_packet .= '</query>';
- } else if ($qid) {
- $xml_packet .= '<qid>' . $qid . '</qid>';
- } else if ($qname) {
- $xml_packet .= '<qname>' . $qname . '</qname>';
- } else {
- return false;
- }
- $xml_packet .= '<fmt>' . $fmt . '</fmt>';
- if ($clist) {
- $xml_packet .= '<clist>' . $clist . '</clist>';
- }
- if ($slist) {
- $xml_packet .= '<slist>' . $slist . '</slist>';
- $xml_packet .= '<options>' . $options . '</options>';
- }
- if ($this->app_token) {
- $xml_packet .= '<apptoken>' . $this->app_token . '</apptoken>';
- }
- $xml_packet .= '<ticket>' . $this->ticket . '</ticket></qdbapi>';
- $response = $this->transmit($xml_packet, 'API_DoQuery');
- } else {
- // If not an xml packet
- $url_string = $this->qb_ssl . $this->db_id . "?act=API_DoQuery&ticket=" . $this->ticket . "&fmt=" . $fmt;
- $pos = 0;
- if ($queries) {
- $url_string .= "&query=";
- foreach ($queries as $query) {
- $criteria = "";
- if ($pos > 0) {
- $criteria .= $query['ao'];
- }
- $criteria .= "{'" . $query['fid'] . "'." . $query['ev'] . ".'" . $query['cri'] . "'}";
- $url_string .= $criteria;
- $pos++;
- }
- } else if ($qid) {
- $url_string .= "&qid=" . $qid;
- } else if ($qname) {
- $url_string .= "&qname=" . $qname;
- } else {
- return false;
- }
- if ($clist) {
- $url_string .= "&clist=" . $clist;
- }
- if ($slist) {
- $url_string .= "&slist=" . $slist;
- }
- if ($options) {
- $url_string .= "&options=" . $options;
- }
- $response = $this->transmit($url_string);
- }
- if ($response) {
- return $response;
- }
- return false;
- }
Add Comment
Please, Sign In to add comment