代码:从多个表中选择 [英] Codeigniter: Select from multiple tables
本文介绍了代码:从多个表中选择的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何从两个或多个表中选择行?
How can I select rows from two or more tables?
我设置表单的默认字段,我需要两个表的值...
I'm setting default fields for a form, and I need values from two tables...
我当前的代码如下:
$this->CI->db->select('*');
$this->CI->db->from('user_profiles');
$this->CI->db->where('user_id' , $id);
$user = $this->CI->db->get();
$user = $user->row_array();
$this->CI->validation->set_default_value($user);
推荐答案
用户指南中的示例应该解释: / p>
The example in the User Guide should explain this:
$this->db->select('*'); // <-- There is never any reason to write this line!
$this->db->from('blogs');
$this->db->join('comments', 'comments.id = blogs.id');
$query = $this->db->get();
// Produces:
// SELECT * FROM blogs
// JOIN comments ON comments.id = blogs.id
请参阅活动记录页面。
这篇关于代码:从多个表中选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文