开发者

How to write this SQL statement in CodeIgniter's Active Record

开发者 https://www.devze.com 2023-01-03 04:57 出处:网络
How to write this SQL statement in Active Record: $this->db->query(\'SELECT a.slogan, a.brief, u.id, u.name FROM example_tbl AS a, users AS u 开发者_开发技巧WHERE u.user_id = \"\' . USER_ID . \

How to write this SQL statement in Active Record:

$this->db->query('SELECT a.slogan, a.brief, u.id, u.name FROM example_tbl AS a, users AS u 开发者_开发技巧WHERE u.user_id = "' . USER_ID . '"');

Please help. Thanks.


$this->db->select('a.slogan, a.brief, u.id, u.name')->where('u.user_id', USER_ID)->get('example_tbl AS a, users AS u')->result();

If your selected table fields are not ambiguous you can drop shortcutting like 'AS a, u'...

0

精彩评论

暂无评论...
验证码 换一张
取 消