Reputation: 737
I have a MySQL database with two schemas, the default one and other called rabbit_db. When I try to access the model it throws the following exception:
Table rabbit_db.api_promos for model Promo was not found in datasource default.
When I create the same table inside the default schema it is working fine.
This is my model:
class Promo extends BaseModel {
public $useTable = 'rabbit_db.api_promos';
public $name = 'Promo';
}
What can I do ?
Upvotes: 0
Views: 97
Reputation: 1615
You either need to change your default datasource or add another one in /app/Config/database.php
.
Here is the documentation on setting up datasources (assuming you are using CakePHP 2.x).
And here is an example showing how to specify which datasource the model should use.
The important part in that example (after defining the 2nd datasource in database.php) is to set the variable $useDbConfig
inside your model so it knows which datasource to use. In your case it might look like this:
class Promo extends BaseModel {
public $useTable = 'rabbit_db.api_promos';
public $name = 'Promo';
public $useDbConfig = 'rabbit_db';
}
Upvotes: 1