Welcome Guest, Not a member yet? Register   Sign In
Problem: CI executes query on wrong database!
#1

[eluser]AlexandrosG[/eluser]
I have this piece of code:

Code:
$sql = "UPDATE $this->table SET password = '$profile[password]', name = '$profile[name]', email = '$profile[email]', info = '$profile[info]' WHERE userid = '$profile[userid]'";
$this->lisdb->query($sql);

inside a model.
When i echo "$this->table" , i get "smith1_users".
When i echo "$this->lisdb->database" i get "mylis0_lisdb".
BUT when i try to execute the above code i get:

Code:
Error Number: 1146
Table 'mylis0_lispdb.smith1_users' doesn't exist


What is going wrong here??? Why CI tries to connect to wrong database? :-(


Note: The model's method that the code belongs connects to 3 databases manually using a separate model property to store each database object. The above piece of code is being calld from inside an iframe.
#2

[eluser]AlexandrosG[/eluser]
Ok! I found the root of the problem.
I was loading multiple databases that all of them were using persistent connections (pconnect = TRUE).
Persistent connections caused some kind of problem. I set 'pconnect = FALSE' to all my connections and problem solved.




Theme © iAndrew 2016 - Forum software by © MyBB