Adding table prefix to join in Codeigniter

后端 未结 2 1153
耶瑟儿~
耶瑟儿~ 2021-01-17 01:02

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

2条回答
  •  失恋的感觉
    2021-01-17 01:28

    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

提交回复
热议问题