Home » Php » php – CakePHP has the wrong model name

php – CakePHP has the wrong model name

Posted by: admin July 12, 2020 Leave a comment


I’m trying out CakePHP now and I can’t get my app working because CakePHP “thinks” my model name is ‘Tach’ when it’s in fact ‘Tache’.

Why so ?

My controller is defined as :

class TachesController extends AppController {

function index() {

    $allTaches = $this->Tache->find('all');

    $this->set('taches', $allTaches);



And here’s my model :

class Tache extends AppModel {

var $useTable = 'taches';


I get an error if I use ‘Tache’ in my controller :

        $allTaches = $this->Tache->find('all');

But if I use ‘Tach’, I get no error :

        $allTaches = $this->Tach->find('all');

Why can’t I use the model name ‘Tache’ ? Am I doing something wrong ? By the way I’m on php 5.3 and my CakePHP version is 1.3.8

Thanks !


How to&Answers:

CakePHP’s default inflection rules think that Taches is the plural form of Tach.

You’ll need to use the Inflector class to add a custom inflection.

See the following:

To recap you’ll need to add something like the following to your app/config/bootstrap.php file:

Inflector::rules('plural', array('irregular' => array('tache' => 'taches')));


You can set $uses with the model name in the TachesController:

class TachesController extends AppController {

    var $uses = 'Tache';