New to Grocery CRUD, I attempted to search for a possible solution and wasn't able to find someone else with this issue.
I have multiple databases I connect to for my site (a sales database, an article database, a stats database) - I do this by having all of my models inherit from a master model which controls the setup dynamically by a constructor call (which sets the database configuration and loads the database) - I also use the parent class to switch the environment database settings (production, testing, dev), so, we're pretty messy when it comes to the configuration - but it is all working as it should for me. The down side is all of the database calls aren't on the main database class ($this->db->...) they are under DB2 ($this->DB2->....)
....
LOL - I answered my own question as I was typing that last bit - I simply did a search and replace on the database function call in the grocery_CRUD_Model from $this->db to $this->DB2 and it worked. (well, I've got to now figure out why the output isn't displaying right style/js paths and all, but it is pulling the correct database data)
I'll post just in case someone else wants to work with a varied database config and this helps (I did also have the grovery_CRUD_Model extend my master controller and updated the constructor to call the config setting per the database I wanted loaded, I'll make it dynamic in the future)
Multi database setup
Started by kaosweaver, 21 May 2012 - 21:41 PM
- Single Page
Posted 21 May 2012 - 21:41 PM
Posted 21 May 2012 - 21:48 PM
You don't need to. This question has been answered without changing the core functionality of grocery CRUD. /topic/420-answered-can-i-switch-databases/