I’m sure this issue can be solved rapidly, but I don’t find any answer on the web, so here I am. I want to call a function from another controller, but CakePHP does not recognize it as a function but as a query, returning a warning:
Warning (512): SQL Error: 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'goals' at line 1 [CORE/cake/libs/model/datasources/dbo_source.php, line 673]
Here’s the logic of what I am trying to do:
//from the TeamController
$this->Team->Player->goals()
//in the PlayerController
function goals() {
//code
}
As you can guess by the names, a Team hasMany Players and a Player belongsTo a Team. I thought this was the way to deal with it, but it’s obviously not working because the cake wants to launch an SQL query starting by “goals”.
Cheers,
Nicolas.
None of the solutions here worked and it looked like the function had to be slightly different from the one on the other controller, so I decided to rewrite a new one in the controller.