Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Codeigniter database join with extra variable

I want to join two tables but comparison is with external variable, like $ext_user

$this->db->join('ec_details2', 'ec_details.user_id = ec_users.user_id','INNER');

Instead of ec_users.user_id in above code i want to use $ext_user, how can i do this like below?

$this->db->join('ec_details2', 'ec_details.user_id = $ext_user','INNER');

If i do with my 2nd option it will not take $ext_user as variable, but taking as complete string!

Thanks,

like image 567
rjcode Avatar asked Apr 25 '26 10:04

rjcode


1 Answers

I think it is about variables will not be expanded when they occur in single quoted strings.

And it work by the double-quoted.

$this->db->join('ec_details2', "ec_details.user_id = $ext_user",'INNER');
like image 132
JohnZ Avatar answered Apr 28 '26 03:04

JohnZ