CodeIgniter Forums
Database query calls wrong DB instance!! - 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: Database query calls wrong DB instance!! (/showthread.php?tid=38922)

Pages: 1 2


Database query calls wrong DB instance!! - El Forum - 02-23-2011

[eluser]Swedie[/eluser]
I have encounter a very mysterious problem that I cannot debug.

On my local test server things are working as expected. On the production server, with the exact same Apache, PHP and MySQL, CI apparently tried to run a query from another instance than the one I'm doing the query through.

The query fails with CI saying it can't find: databasename.sometable.

My application is a controller and lots of models.

I've run print_r on both the complete CI object and the DB instance and the database settings are all correct. But when running the query, CI for some reason is digging in the wrong DB instance and thus not finding the table.

What can be causing this?


Database query calls wrong DB instance!! - El Forum - 02-23-2011

[eluser]Swedie[/eluser]
Btw, I can get around this if I inside the model function run for example:
$this->DB = $this->load->database("smc", TRUE);

Then the model knows where to look.

But this is already set in the controller! And it works fine on my own computer (dev. environment).


Database query calls wrong DB instance!! - El Forum - 02-24-2011

[eluser]Swedie[/eluser]
Noone have an idea here?


Database query calls wrong DB instance!! - El Forum - 02-24-2011

[eluser]Swedie[/eluser]
Once again I had to solve this on my own. This community is a little slow sometimes. Too slow! Makes me wonder if I've made the right choice of MVC framework.

The problem I had was due to DB username/passwords being the same for two DB instances. This makes it confusing apparently and it caused the weird behavior described in the first post.


Database query calls wrong DB instance!! - El Forum - 02-24-2011

[eluser]danmontgomery[/eluser]
[quote author="Swedie" date="1298578359"]Once again I had to solve this on my own. This community is a little slow sometimes. Too slow! Makes me wonder if I've made the right choice of MVC framework.

The problem I had was due to DB username/passwords being the same for two DB instances. This makes it confusing apparently and it caused the weird behavior described in the first post.[/quote]

You offer a vague description of a problem with no actual error messages, you offer no code, and then complain when the community of volunteers don't immediately run out and solve this problem within 24 hours? You have unrealistic expectations.


Database query calls wrong DB instance!! - El Forum - 02-24-2011

[eluser]Swedie[/eluser]
No one made an attempt to take the discussion though.

I can't post over 20k lines of code here from 10 different models. That's an unrealistic requirement as well.

But surely for next time I'll try to post error codes and bit more code.


Database query calls wrong DB instance!! - El Forum - 02-24-2011

[eluser]beaufrusetta[/eluser]
I lol'd.

Being as detailed as possible will help all of us help you better. Posting up code snippets (not 20k lines of them) is always helpful, as it allows us to recreate the situation. Smile


Database query calls wrong DB instance!! - El Forum - 02-24-2011

[eluser]Developer13[/eluser]
[quote author="Swedie" date="1298582059"]No one made an attempt to take the discussion though.

I can't post over 20k lines of code here from 10 different models. That's an unrealistic requirement as well.

But surely for next time I'll try to post error codes and bit more code.[/quote]

Maybe having over 20k lines of code in your models is part of your problem.... just sayin'...


Database query calls wrong DB instance!! - El Forum - 02-24-2011

[eluser]InsiteFX[/eluser]
Well I know I test avery methods that I create to make sure it works

Create new method
Document new method
Test new method input and output
Test new method for limits etc.

Debug your code as your building it.

If you wait until the end to check this stuff, your in for a nightmare!!!

InsiteFX


Database query calls wrong DB instance!! - El Forum - 02-25-2011

[eluser]Swedie[/eluser]
It's a ported system that don't fully use the views yet. Using views will reduce a lot of textual output code.

But the problem this time was not in the models, it had to do with something core, as I told above. My last resort was to post a thread to get help.

But do not start to hunt me now for complaining a little about slowness of the commmunity at times.