Skip to content

Purge_records when XML= true #8

@armandoramirezdino

Description

@armandoramirezdino

Hi, i detect a problem using the method: purge_records

Im leaving here the fix i did to get it working:

/* API_PurgeRecords: http://www.quickbase.com/api-guide/index.html#purgerecords.html */
public function purge_records($queries = 0, $qid = 0, $qname = 0) {

if($this->xml) {
		
	
		$xml_packet='<qdbapi>';
		$pos = 0;
		if ($queries) {
			$xml_packet.='<query>';
			foreach ($queries as $query) {
				$criteria = "";
				if($pos > 0) {
					$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;
		}
		


		if ($this->app_token)
			$xml_packet .= '<apptoken>' . $this->app_token . '</apptoken>';
		$xml_packet .= '<ticket>'.$this->ticket.'</ticket>
			</qdbapi>';
			

	$response = $this->transmit($xml_packet, 'API_PurgeRecords');
	}	


	else {
		$url_string = $this->qb_ssl . $this->db_id. "?act=API_PurgeRecords&ticket=". $this->ticket;
		if ($queries) {
		$pos = 0;
			$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;
		}
		$response = $this->transmit($url_string);
	}
	if($response) {
		return $response;
	}
	return false;
}	

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions