CodeIgniter Forums
dbprefix does not do what I want it to do. - 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: dbprefix does not do what I want it to do. (/showthread.php?tid=22056)



dbprefix does not do what I want it to do. - El Forum - 08-28-2009

[eluser]John_Betong[/eluser]
 
I decided to try and use Active Record throughout a new project and the following error occurred:
Code:
// database.php configuration
      $db['default']['database'] = 'johnsjokes';
      $db['default']['dbprefix'] = 'XXXXX_';


   // my_model.php ActiveRecord call
      $total = $this->db->count_all('articles');


      A Database Error Occurred
      Error Number: 1146
      Table 'johnsjokes.XXXXX_articles' doesn't exist
      SELECT COUNT(*) AS `numrows` FROM `XXXXX_articles`
 
I would have thought that the XXXXX_ should be prefixing the database name and not the table.
 
Is this a bug?
 
 
 


dbprefix does not do what I want it to do. - El Forum - 08-28-2009

[eluser]pistolPete[/eluser]
[quote author="John_Betong" date="1251459600"]I would have thought that the XXXXX_ should be prefixing the database name and not the table.[/quote]

Read the user guide: http://ellislab.com/codeigniter/user-guide/database/configuration.html
Quote:dbprefix - An optional table prefix which will added to the table name when running Active Record queries. This permits multiple CodeIgniter installations to share one database.



dbprefix does not do what I want it to do. - El Forum - 08-28-2009

[eluser]John_Betong[/eluser]
[quote author="pistolPete" date="1251459787"][quote author="John_Betong" date="1251459600"]I would have thought that the XXXXX_ should be prefixing the database name and not the table.[/quote]

Read the user guide: http://ellislab.com/codeigniter/user-guide/database/configuration.html
Quote:dbprefix - An optional table prefix which will added to the table name when running Active Record queries. This permits multiple CodeIgniter installations to share one database.
[/quote]
 
Many thanks for the clarification.
 
Maybe it should be renamed to tableprefix so that I will not get confused with the prefix that my host uses for all database names.