multiple database, persistent connection |
[eluser]broadband[/eluser]
I tried this code: Code: [b]MySQL database test1:[/b] Output is: Code: resource(5) of type (mysql link) This means that you can have persistent connection for multiple databases. You just have to use mysql_select_db. In codeigniter if I use this: Code: database.php
[eluser]broadband[/eluser]
The output of function test() is: Code: A Database Error Occurred
[eluser]broadband[/eluser]
This must be a bug within codeigniter, because the first code shows that you can one persistent connection and use different database.
[eluser]broadband[/eluser]
Found that this already is a bug: http://ellislab.com/forums/viewthread/157298/#843990 This is the best solution to the problem. There is a bug in CI. 1 line of code fixes it so you can do stuff like… $a = $this->load->database(‘default’, TRUE); $b = $this->load->database(‘default’, TRUE); ...without the second call to load->database overwriting the first. Here is the bugfix: http://koorb.wordpress.com/2007/11/16/co...comment-40 Or if you don’t want to go there… #####start bugfix##### Description all of the database calls go to the same database (last one initialized) To fix the probleme change the simple_query function in DB_driver.php: function simple_query($sql) { if ( ! $this->conn_id) { $this->initialize(); } $this->db_select(); //Added this line return $this->_execute($sql); } #####end bugfix#####http://ellislab.com/forums/viewthread/157298/#843990
[eluser]InsiteFX[/eluser]
Report it as a BUG! You should never edit CodeIgniter core classes! Just think what is going to happen when you upgrade to a new version and copy the system directory over...
[eluser]d3ptzz[/eluser]
I have same problem, and i just change one line in config/database.php to fix it change value of this: $db['test1']['pconnect'] = TRUE; $db['test2']['pconnect'] = TRUE; to FALSE : $db['test1']['pconnect'] = FALSE; $db['test2']['pconnect'] = FALSE; and done! |
Welcome Guest, Not a member yet? Register Sign In |