|
本帖最后由 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( [0] => Array (
[id] => 1
[stroe_name] => stroe_name
[goods] => Array
(
[0] => Array
(
[good_id] => 1
................
)
)
........................
)
[1] => Array (
[id] => 2
[stroe_name] => stroe_name
[goods] => Array
(
[0] => Array
(
[good_id] => 2
................
)
)
........................
)
)
|
|