我无法让 delete_record 功能工作。这是我当前使用的 delete_record 代码:
$qb->db_id = $myQbTables["table1"]; //using table 1 now
$queries = array( //this is the where clause now for the delete query
array(
'fid' => '12',
'ev' => 'EX',
'cri' => '1175'
),
array(
'fid' => '8',
'ev' => 'EX',
'cri' => $Child_ID
)
);
$results = $qb->do_query($queries, '', '', 'a', '1', 'structured', 'sortorder-A'); //get all results
if($results->errCode !== 0) {
echo $results->errTxt;
}
print_r($results);
foreach($results->table->records->record as $record){ //getting results of delete query
$Deletevar = $record->f[11];
$deleted = $qb->delete_record($Deletevar); //deleting results
print_r($deleted);
}
我知道“cri”与我的快速库中的内容相匹配,但我似乎无法使用 f[3](记录 ID)来删除它!
笔记
我找到了我遇到的主要问题!如果您使用 QB API 进行 API 调用,删除记录和清除记录不包括应用令牌!!请使用以下代码更新 delete_records 函数!!!!
public function delete_record($rid) {
if($this->xml) {
$xml_packet = new SimpleXMLElement('<qdbapi></qdbapi>');
$xml_packet->addChild('rid',$rid);
$xml_packet->addChild('ticket',$this->ticket);
$xml_packet->addChild('apptoken',$this->app_token);
$xml_packet = $xml_packet->asXML();
$response = $this->transmit($xml_packet, 'API_DeleteRecord');
}
else {
$url_string = $this->qb_ssl . $this->db_id. "?act=API_DeleteRecord&ticket=". $this->ticket
."&apptoken=".$this->app_token."&rid=".$rid;
$response = $this->transmit($url_string);
}
return $response;
}