我对 codeigniter 很陌生,正在尝试 JOIN 操作。我的数据库表users
结构是
id username password user_type cust_id
8 abc xyz cust 7
和account_numbers
表是
bank_id customer_id ac_number creation_date
3 7 12345 2013-06-12
为了获取已知用户 ID 的帐号,我写了
function get_ac_no($user_id)
{
//echo $user_id;
$this->load->database();
$this->db->select('ac_number');
$this->db->from('account_numbers');
$this->db->join('users','account_numbers.customer_id = users.id');
$this->db->where('customer_id ',$user_id);
$this->db->limit(1);
$q = $this->db->get();
$r = $q->result();
var_dump( $r );
return $r;
}
但它显示空结果!你能建议我做错了什么吗?