• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Database Prefix Problem

#1
[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?

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

InsiteFX

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

#4
[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-pref...deigniter/

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?

#5
[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.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.