Focus on IT Recommend

Home > mysql - Cake PHP Table not found in datasource

mysql - Cake PHP Table not found in datasource



I added a table sitewebs in my existing database. So I created a class Model Siteweb :

App::uses('AppModel', 'Model');
 * Siteweb Model
class Siteweb extends AppModel {
 * Display field
 * @var string
    public $displayField = 'nom';

The connection parameters for the database are correct, and the user has all the rights on this table (When I generate the shema via command line php cake.php schema generate -f, although the table appears in the file shema.php).

My Configuration

  • PHP 5.6.12
  • MySQL 5.5.44
  • Cake 2.1.3

What I tried to do to solve the problem

  • Clear cache files from app/tmp/cache/models and app/tmp/cache/persistent
  • Rename table and force it in Model file : public $useTable = 'sites';
  • Grant All privileges to my MySQL user : grant all privileges on mybase.* to myuser@'localhost';flush privileges;

But I still have the error Table sitewebs for model Siteweb was not found in datasource default.

Look at the code of my controller :

Recommend:php - MySQL Query Logging in CakePHP

we use the find method on the models, I know that rails database queries, so does Cake do the same, if so how can I enable it or use it Shiv php mysql logging cakephp
  this question asked May 23 '09 at 21:33 Shiv 5,530 4 22

try {
} catch (Exception $ex) {

Except this controller, the application is functional.

Any idea ?

php mysql cakephp cakephp-2.0
  this question
asked Oct 28 '15 at 9:43 Gildas Rossignon 1,359 1 12 26


1 Answers


Just set debug var to refresh cache files, solve my problem :

Configure::write('debug', 2);

  this answer
answered Oct 28 '15 at 12:27 Gildas Rossignon 1,359 1 12 26


Recommend:mysql - Cake model bake Error: The datasource configuration "493" was not found in database.php

ng Error on console Creating file C:\wamp\www\projectnexus\app\Model\Role.phpError: The datasource configuration "493" was not found in database.php it comes after Look okay (y/n)[y] >array(0) {}Notice Error: Undefined offset: 0 in

------splitte line----------------------------