-1
我在將返回的結果從數據庫SQL映射器處理成可識別的json編碼數組時遇到問題。來自fatfree DB SQL Mapper的json編碼處理結果
function apiCheckSupplyId() {
/*refer to the model Xrefs*/
$supply_id = $this->f3->get('GET.supply_id');
$xref = new Xrefs($this->tongpodb);
$supply = $xref->getBySupplyId($supply_id);
if (count($supply) == 0) {
$this->logger->write('no xref found for supply_id=' .$supply_id);
$supply = array(array('id'=>0));
echo json_encode($supply);
} else {
$json = array();
foreach ($supply as $row){
$item = array();
foreach($row as $key => $value){
$item[$key] = $value;
}
array_push($json, $item);
}
$this->logger->write('xref found for supply_id=' .$supply_id.json_encode($json) );
echo json_encode($json);
}
}
這是我使用的方法,但對我來說似乎很笨重。有沒有更好的辦法?
您希望每個供應有多少外部輪廓? 1?或者更多? – xfra35
其中一個將是理想的,但在這個古怪的世界中無法保證 –