Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Purge_records when XML= true #8

Open
armandoramirezdino opened this issue Feb 16, 2017 · 0 comments
Open

Purge_records when XML= true #8

armandoramirezdino opened this issue Feb 16, 2017 · 0 comments

Comments

@armandoramirezdino
Copy link

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;
}	
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant