I have a fresh baked (with bake console) project in which I have 2 models behaving differently when I call model->find function.
UsersController
public function index() {
$this->User->recursive = 0;
$this->set('users', $this->paginate());
}
WordsController
public function index() {
$this->Word->recursive = 0;
$this->set('words', $this->paginate());
}
Query (DebugKit)
SELECT `Word`.`*` FROM `words` AS `Word` WHERE `Word`.`iniziale` = 'A' AND `Word`.`pubblicata` = '1' ORDER BY `Word`.`parola` ASC LIMIT 10
Affected 10
Num rows 10
In both cases the query inspected has affected rows, but the WordsController doesn’t return any results if I debug the paginate() result, while the Users one gives correctly.
Word model has no relations, and I tried to change the model name to Term, obtaining the same result.
I tried also to downgrade CakePHP core to 2.1.4. Nothing.
Are there any possible causes to this problem? Is Word some kind of reserved keyword? How can this be debugged?
I figured it out.
I had in the words table (UTF8), some texts containing special characters like àòèéìù. Cake removed all the result containing these characters. I tried replacing “è” with “e” and magically the record was available in Cake!
Hope my 5 hours of headache will help someone else!