Welcome Guest, Not a member yet? Register   Sign In
Test database
#1

[eluser]Unknown[/eluser]
I'm am auto loading the database library and I am wondering if there is a way to specify a test database when I load a specific controller. I tried adding a second set of database parameters in the main database library and then calling $this->load->database('test') at the beginning of my testing controller but no luck.

Thanks in advance,
Chris
#2

[eluser]Eric Barnes[/eluser]
If you are autoloading it then you would have to do something like:
Code:
$DB2 = $this->load->database('group_two', TRUE);

Then use:
Code:
$DB2->query();

Another way could be to load the db through a MY_Controller and then hook into router to see what method you are in. I guess the bigger question is why you would want to do that. Smile
#3

[eluser]Unknown[/eluser]
[quote author="Eric Barnes" date="1296299996"] I guess the bigger question is why you would want to do that. Smile[/quote]

I am working on a new part of my application and would like to develop and test it on a copy of the current production database. Can you recommend a different way?

Thanks for your quick response,
Chris
#4

[eluser]Eric Barnes[/eluser]
Well the simplest way would be to dump the production db and run it locally so you can develop off an exact copy. Which at a minimum is ideally what you always want to do. You really should never develop directly against production.

What I personally do which may be out of scope for what you are trying to do is set a constant in the index file which I then use to load the correct db for the environment. Something like define('ENVIRONMENT', 'local'); then in the db config check if it is local or production and then load the correct group.




Theme © iAndrew 2016 - Forum software by © MyBB