我需要从具有相同名称的数据库中获取数据。我使用 json 数组来获取输出。
function search_review($input, $serviceName){
$data = array();
$ipJson = json_encode($input);
$this->db->select('*');
$this->db->from('reviews');
$this->db->where('reviewee_name', $input['reviewee_name']);
$query = $this->db->get();
$result = $query->result();
if (!empty($result)) {
foreach ($query->result() as $row)
{
$data[]['reviewer_id'] = $row->reviewer_id;
$data[]['reviewee_name'] = $row->reviewee_name;
$data[]['tournament_played_c_s'] = $row->tournament_played_c_s;
}
$data['message'] = 'Review details retrieved successfully.';
$status = $this->clamo_lib->return_status('success', $serviceName, $data, $ipJson);
} else {
$data['message'] = 'Unable to retrieve review details.';
$status = $this->clamo_lib->return_status('error', $serviceName, $data, $ipJson);
}
return $status;
}
0输出:
我需要得到我的输出
<data>
<_0/>
<message>Review details retrieved successfully.</message>
<reviewee_name>deepi</reviewee_name>
<reviewer_id>4</reviewer_id>
<tournament_played_c_s>karnataka,bangalore</tournament_played_c_s>
</data>
<data>
<_1/>
<message>Review details retrieved successfully.</message>
<reviewee_name>deepi</reviewee_name>
<reviewer_id>5</reviewer_id>
<tournament_played_c_s>kerala</tournament_played_c_s>
</data>
我必须改变什么?