$list = Db::table('pet_info')->select();
//查询图片
// return json_encode($list);
for($i = 0;$i< count($list);$i++){
$pid = $list[$i]['id'];
$list[$i]['imgsrc']=Db::table('upload_img')->where("uoload_pet_id",$pid)->select();
}
$this->assign('list',$list);
// return json_encode($list);
return $this->fetch();
效果
[{
"id": 1,
"pet_name": "Ceshi ",
"pet_src1": "",
"pet_src2": "",
"pet_src3": "",
"kinds": 0,
"pet_sex": 0,
"pet_age": 0,
"pet_health": 0,
"pet_breed": "",
"pet_desc": "",
"pet_publi": "15368666279",
"pub_name": "\u547c\u547c\u547c",
"pub_address": "\u54c8\u54c8\u54c8",
"pub_phone": "11111111111",
"imgsrc": [
{
"id": 1,
"src": "xxxxx.png "
},
{
"id": 2,
"src": "xxxxx.png "
}
]
}]