CodeIgniter Forums
database before routes - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: Best Practices (https://forum.codeigniter.com/forumdisplay.php?fid=12)
+--- Thread: database before routes (/showthread.php?tid=67539)



database before routes - ponzo - 03-07-2017

Im building a multisite where each site setting is loaded from the databse based on the subdomain or domain . this works great

However : how would point different application folders for each site.

Lets say site 1 is using version 1 of the application
Lets site 2 is using version 2 

The only idea I came up is to put the MVC and libraries in a version named folder. 
And use a constant for the version named folder in routes.php
But it seems the routes.php is loaded before database.php
And database.php is the place where I can point which site uses which version

Any ideas?


RE: database before routes - InsiteFX - 03-07-2017

You could use your own standard MySQLi connection and retrieve the information from the database.


RE: database before routes - ponzo - 03-07-2017

(03-07-2017, 05:02 AM)InsiteFX Wrote: You could use your own standard MySQLi connection and retrieve the information from the database.

Thanks. thats an option.

I'm not really on perfomance yet but I already use a PDO connection in the database.php
Then I should do the same PDO connection in routes.php 

Or maybe I can do a single PDO connection in routes.php, and then pass database connection setup to database.php ?

 And is it recommended to use a folder structure like this

application
   config
   core (etc)
   version 1 
      - model
      - view
      - controller
   version 2
      - model
      - view
      - controller