[eluser]atompkins[/eluser]
I have set up two database connections in database.php as shown in the user guide.
In my controller I have declared two class-level properties to represent each database connection. In the constructor I have the following code:
Code:
$this->appMgmtDB = $this->load->database('AppMgmt',TRUE);
$this->movieDB = $this->load->database('Movie',TRUE);
When I access the 'movieDB' connection, everything is fine but when I try to use the 'appMgmtDB' connection the queries will always fail unless I fully qualify the table names.
For example, this code:
Code:
$sql = "SELECT Id FROM User WHERE LoginName = ? AND Password = ?";
$query = $this->appMgmtDB->query($sql, array($loginName, $password));
will produce the following error:
Quote:Table 'Movies.User' doesn't exist
unless I change the SQL to the following:
Code:
$sql = "SELECT Id FROM AppMgmt.User WHERE LoginName = ? AND Password = ?";
For some reason, if the table is not fully qualified, it thinks that I'm querying the wrong database (Movies instead of AppMgmt) even though the connection object should be pointing at the AppMgmt database and a fully qualified table name is unnecessary.
All the queries against the movieDB connection work fine without the need to fully qualify the tables.
I'm out of ideas, can anyone suggest what might be wrong?
Thanks.
- Adam