php ci框架 查询mysql 返回json数组 255
我要获得的效果是:[{"name":"aaa","id":"1","sex","man"},{"name":"bbb","id":"2","sex","woman"},{...
我要获得的效果是:[{"name":"aaa","id":"1","sex","man"},{"name":"bbb","id":"2","sex","woman"},{}...]我现在的显示,和我的代码。怎么改,直接截图放修改后的代码实例即可请具体问题具体分析
我现在的显示是{"name":"aaa","id":"1","sex","man"}{"name":"bbb","id":"2","sex","woman"}{}...
前面结果显示有点长了,代码那个图片在后面 展开
我现在的显示是{"name":"aaa","id":"1","sex","man"}{"name":"bbb","id":"2","sex","woman"}{}...
前面结果显示有点长了,代码那个图片在后面 展开
1个回答
展开全部
返回给数组的写法:
$query3 = $this->db->query("select * from constrproj where ConstrProjID= ( SELECT min(ConstrProjID) from constrproj)");
$arr = $query3->result_array();
$ParentID = $arr[0]['ConstrProjID']; (操作键值。 因为它是二维数组,所以这么写)
返回给对象的写法:
$query3 = $this->db->query("select * from constrproj where ConstrProjID= ( SELECT min(ConstrProjID) from constrproj)");
$arr = $query3->result();
foreach ($arr as $v){
$ConstrProjID = $v->ConstrProjID; (操作属性)
}
$query3 = $this->db->query("select * from constrproj where ConstrProjID= ( SELECT min(ConstrProjID) from constrproj)");
$arr = $query3->result_array();
$ParentID = $arr[0]['ConstrProjID']; (操作键值。 因为它是二维数组,所以这么写)
返回给对象的写法:
$query3 = $this->db->query("select * from constrproj where ConstrProjID= ( SELECT min(ConstrProjID) from constrproj)");
$arr = $query3->result();
foreach ($arr as $v){
$ConstrProjID = $v->ConstrProjID; (操作属性)
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询