在codeigniter中加入两个以上的表

时间:2011-04-21 11:13:49

标签: php codeigniter

我有4个表,我想在codeigniter中一起加入那些表。是否可以使用codeigniters join方法?

2 个答案:

答案 0 :(得分:8)

如果您正在使用CodeIgniter的Active Record类,则可以多次使用join方法来连接多个表。

$this->db->join('table2', 'table2.ID = table1.ID');
$this->db->join('table3', 'table3.ID = table1.ID');
$this->db->join('table4', 'table4.ID = table1.ID', 'left');

答案 1 :(得分:0)

我假设您正在谈论加入SQL数据库表,这是正确的吗? 如果是这样,您始终可以使用CodeIgniter SQL方法,请参阅:http://codeigniter.com/user_guide/database/queries.html