我在 php 中有一种方法可以像这样执行存储过程:
Function GetInTransitAndDelivery($Parameter)
{
$this->load->database();
$query = $this->db->query( " EXEC StoredProcedureName $Parameter");
if (count($query->num_rows()) > 0)
{
$result = array();
foreach ($query->result() as $row)
{
$result[] = array("EffectiveStatusId"=>$row->EffectiveStatusId,
"EffectiveStatus"=>$row->EffectiveStatus,
"RecordCount"=>$row->RecordCount);
}
}
return $result;
}
这给了我这样的结果:
{
"GetInTransitAndDeliveryResponse":[
{
"EffectiveStatusId":1,
"EffectiveStatus":"abc",
"RecordCount":7
},
{
"EffectiveStatusId":6,
"EffectiveStatus":"efg",
"RecordCount":91
}
]
但我不会像这样:
{
"GetInTransitAndDeliveryResponse":[
{
"EffectiveStatusId":1,
"EffectiveStatus":"abc",
"RecordCount":7
},
{
"EffectiveStatusId":1,
"EffectiveStatus":"efg",
"RecordCount":7
},
{
"EffectiveStatusId":1,
"EffectiveStatus":"hij",
"RecordCount":0
},
{
"EffectiveStatusId":6,
"EffectiveStatus":"klm",
"RecordCount":0
}
]
那么如何在结果数组中追加元素
提前致谢