I have Codeigniter setup to add the prefix kms_ to my active record queries. However, I am trying to do a join with two ON conditions and it doesn\'t prepend them.
R
You can get the current database prefix manually like this:
$prefixed_tablename = $this->db->dbprefix('tablename');
So you could do this:
$this->db->join('site_items', $this->db->dbprefix('site_items') . '.item_id = ' . $this->db->dbprefix('items') . '.id AND ' . $this->db->dbprefix('site_items') . '.site_id = 1', 'left');
Docs Here
You can simply add Prefix
table name like this :
for example your tables have myPrefix_
as prefix and one of them might be myprefix_user
.
After that in your config/database.php
at the bottom of this page where you set your database name
, username
and password
, You can see dbprefix
and you can set your prefix as I mentioned above myPrefix_
.
At the end, You can simply call your table name for example $this->db->get('user')
and automatically Codeigniter set your prefix at the first of it.