multiple db connection issue |
[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
[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
[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
[eluser]Dam1an[/eluser]
No worries, we've all been there (me too ) At least you'll know what to look for next time
[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.
[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!!!
[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 |
Welcome Guest, Not a member yet? Register Sign In |