I have just a table on my database named "ficha_seg". The name of my model file is "Ficha.php" and the name of the controller is "FichasController.php".
So, why i'm getting the error:
Error: Table fichas for model Ficha was not found in datasource default.
after configured my index() method of controller like this:
public function index() {
$this->set('ficha_seg', $this->Ficha->find('all'));
}
By default, the model uses the lowercase, plural form of the model’s class name for the database table name.
If you need to use another table name for your model, you can use the useTable
attribute:
class Ficha extends AppModel
{
public $useTable = 'ficha_seg';
}
See http://book.cakephp.org/2.0/en/models/model-attributes.html#usetable and Model conventions in the Cookbook
To follow CakePHP conventions your table name should be in plural: ficha_segs
and your model name should be 'FichaSeg'.
If you don't want to follow it for any reason, do what @nlcO says.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With