![]() |
multiple db connection issue - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: multiple db connection issue (/showthread.php?tid=19474) |
multiple db connection issue - El Forum - 06-08-2009 [eluser]theprodigy[/eluser] OK, this may be more than one subject, but here goes..... I am building a module using Matchbox. I need to connect to multiple databases simultaneously. In my model constructor I have Code: function MGalleries() Then, later, I try to use one of them using Code: $db->select('...'); but I am receiving an error Quote:A PHP Error was encountered What am I doing wrong? Is this something wrong with my Matchbox, or am I supposed to call the database loading from a controller and not in the model constructor? Please help, Thanks multiple db connection issue - El Forum - 06-09-2009 [eluser]Dam1an[/eluser] It's because you decalre the variable in the constructor in the constructor, so it's only visible there Try Code: class MGalleries extends Model { You will now need to use $this->db and $this->check in the other functions to use it multiple db connection issue - El Forum - 06-09-2009 [eluser]theprodigy[/eluser] well, damn, I feel like an idiot now. I can't believe I let something like scoping get one over on me. Oh well. Thanks, Dam1an multiple db connection issue - El Forum - 06-09-2009 [eluser]Dam1an[/eluser] No worries, we've all been there (me too ![]() At least you'll know what to look for next time multiple db connection issue - El Forum - 06-09-2009 [eluser]TheFuzzy0ne[/eluser] [quote author="Dam1an" date="1244567467"]At least you'll know what to look for next time[/quote] Yeah, look for Dam1an, he'll help you. ![]() multiple db connection issue - El Forum - 06-09-2009 [eluser]theprodigy[/eluser] heh, I'll be looking here on the forums. I've seen a lot of good knowledge here. A couple snide remarks here and there, but we all have bad days (trust me, this I know ;-) ). I would like to say that ya'll are great, and thanks for taking the time to work with us. I love this community. You guys are the Bean-O to my Brain-farts!!! multiple db connection issue - El Forum - 07-26-2009 [eluser]Jedidiah Reeser[/eluser] I made a video tutorial about connecting multiple databases in CI. I had a similar problem and this video shows the solution that I used. Accessing Multiple Databases in CI Video Tutorial by Jedidiah Reeser |