多表关联查询
本帖最后由 gxcnvip 于 2014-11-19 09:11 编辑请教个问题:
关于多表关联查询,我想要的借返回结果如下,CI的查询语法怎么写?
我是这样写的:
$this->db->select('表1.*, 表2.字段');
$this->db->where( $conditions );
$this->db->join( '表2', '表2.id=表1.表1_id', 'left' );
$this->db->get("orders")->result_array();
Array( => Array (
=> 1
=> stroe_name
=> Array
(
=> Array
(
=> 1
................
)
)
........................
)
=> Array (
=> 2
=> stroe_name
=> Array
(
=> Array
(
=> 2
................
)
)
........................
)
)
没人遇到这种情况么? $this->db->select($value);
$this->db->from('goods');
$this->db->join('category', 'category.cat_id = goods.cat_id','left');
$this->db->join('user', 'user.user_id = goods.user_id','left')->where($condition);
$query = $this->db->get();
return $query->result_array();
不知道自己能看懂。自己领会一下吧!这是我写的关联!
:(:(:(:( 小鱼中国 发表于 2014-11-24 16:29
不知道自己能看懂。自己领会一下吧!这是我写的关联!
这种写关联是没错,但是得不到上面的数组结构
页:
[1]