CodeIgniter Forums
Database Prefix Problem - 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: Database Prefix Problem (/showthread.php?tid=36376)



Database Prefix Problem - El Forum - 11-30-2010

[eluser]CMCDragonkai[/eluser]
I set my database prefix to 'ci_' in order to better separate my ci tables from phpbb's tables.

Now when I try to access phpbb's table, CI automatically adds ci_ to the tablenames. Now phpbb's table names do not have ci_. It has phpbb_. Is there was to tell CI to ignore db prefix for certain queries?


Database Prefix Problem - El Forum - 11-30-2010

[eluser]InsiteFX[/eluser]
ci_ is a reserved name!

InsiteFX


Database Prefix Problem - El Forum - 11-30-2010

[eluser]CMCDragonkai[/eluser]
I don't understand!


Database Prefix Problem - El Forum - 11-30-2010

[eluser]CMCDragonkai[/eluser]
I found out that manual queries ignore table prefix. I also found out that there is a way to add table prefix to manual queries:

According to this: http://crynobone.com/database-table-prefix-in-codeigniter/

In config/database.php

One can do this:

Code:
$db['default']['dbprefix'] = "feed_";  
$db['default']['swap_pre'] = "{PRE}";

So that this can be done:

Code:
$sql = "SELECT * FROM {PRE}item";  
$query = $this->db->query($sql);

The {PRE} becomes feed_.

But swap_pre is not config.php which leads me to think that this is CI 2.0 feature.

Here it means swap_pre for 2.0 http://philsturgeon.co.uk/news/2010/03/codeigniter-2

Will there be a day where we will be able to use this?


Database Prefix Problem - El Forum - 11-30-2010

[eluser]WanWizard[/eluser]
Create a second database config for the same database, but without the prefix. Then use $this->db to access the default database (with prefix) , and
Code:
$this->phpbb = $this->load->database('phpbb', TRUE);
to access the phpbb tables.