Multiple FuelCMS installations, one database

edited November 2014 in Installation
Hello,

is it currently possible to use a single database with multiple FuelCMS installations on a server? I am developing two webites at the moment, and want to house them both under my domain. The thing is, they both use tables like fuel_users and the like.

Is there any way to separate these? I tried setting the dbprefix property in the database.php file, but with a table like "advertisements", setting a prefix "abc_", it seems to display an error, searching for BOTH "advertisements" and "abc_advertisements"! Really weird.

Is there something I'm missing, or is FuelCMS/CodeIgniter just not suitable in this kind of scenario?

Martin

Comments

  • edited 6:22AM
    I haven't tried what I'm about to suggest yet but it may be worth a shot. FUEL has a "tables" config that is used for mapping models to tables. In the fuel/application/config/MY_fuel.php file you could try adding something like this configuration:
    switch ($_SERVER['SERVER_NAME']) { case 'mydomain1.com': // The FUEL specific database tables $config['tables'] = array( 'fuel_archives' => 'fuel_archives', 'fuel_blocks' => 'fuel_blocks', 'fuel_categories' => 'fuel_categories', 'fuel_logs' => 'fuel_logs', 'fuel_navigation' => 'fuel_navigation', 'fuel_navigation_groups' => 'fuel_navigation_groups', 'fuel_pages' => 'fuel_pages', 'fuel_pagevars' => 'fuel_page_variables', 'fuel_permissions' => 'fuel_permissions', 'fuel_relationships' => 'fuel_relationships', 'fuel_settings' => 'fuel_settings', 'fuel_tags' => 'fuel_tags', 'fuel_users' => 'fuel_users' ); break; case 'mydomain2.com': // The FUEL specific database tables $config['tables'] = array( 'fuel_archives' => 'fuel_archives2', 'fuel_blocks' => 'fuel_blocks2', 'fuel_categories' => 'fuel_categories2', 'fuel_logs' => 'fuel_logs2', 'fuel_navigation' => 'fuel_navigation2', 'fuel_navigation_groups' => 'fuel_navigation_groups2', 'fuel_pages' => 'fuel_pages2', 'fuel_pagevars' => 'fuel_page_variables2', 'fuel_permissions' => 'fuel_permissions2', 'fuel_relationships' => 'fuel_relationships2', 'fuel_settings' => 'fuel_settings2', 'fuel_tags' => 'fuel_tags2', 'fuel_users' => 'fuel_users2' ); break;}
  • edited 6:22AM
    Did not know about the table mappings. Worked like a charm for FUEL's tables, thanks! It still doesn't help with custom tables though, even having the prefix in the config file. I guess I'll just have to manually get the prefix when defining the table name in the module's constructor?
  • edited 6:22AM
    You can add to the tables config your own tables that you want to map and then reference that in your constructor and elsewhere in your models.
  • edited 6:22AM
    Okay I've no idea why I didn't try that out...... Thanks a lot for the help!
  • edited March 2020

    Thanks for this, but I have a question what about the database? will the setting still remains? meaning that for all sites they will maintain one database, just the switch that tells which of the tables that is being called. Thanks

  • Thanks works like charm to me too. Appreciate. Again it is not possible to have one installation running multiple sites?

  • Due to the customization of code in the fuel/application directory per website, it's not setup handle multiple sites. You may be able to make some configuration changes in the index.php file to point to different fuel/application directories based on a parameter (e.g. server domain).

Sign In or Register to comment.