CodeIgniter Forums
Help with the dbprefix method - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Help with the dbprefix method (/showthread.php?tid=47151)



Help with the dbprefix method - El Forum - 11-28-2011

[eluser]Unknown[/eluser]
Hello everybody!!

I need some help with the dbprefix config in CI 2.0.3.
By searching the forum, I've found this post : http://ellislab.com/forums/viewthread/87829/#442426
And over there, Colin Williams said that "The dbprefix method just returns a string. It does not alter your queries.".
But since the post is from 2006, I believe that this behavior has changed since.
I'm using dbprefix and it IS altering my queries. It adds the prefix automatically.

Problem is:
I'm using prefixes to identify different languages in the database, like es_table, pt_table, en_table and so on.
And I'm changing the prefix with
Code:
$this->db->set_dbprefix($this->session->userdata('lang'))
But some of the tables are common to all languages, like images, and have no prefix at all.
If the dbprefix method worked like, apparently, it used to work I could just add the method to the queries that use those prefixed tables and use
Code:
$this->db->get($this->db->dbprefix('table'));

Does anyone know if theres a way to change that?