I have carried out various tests and this is the scenario I am faced with.
I have a class ‘Team’ and also a class ‘JobUser’. I would like to call a function ‘getJobUserId’ from the class ‘JobUser’ in a controller.
At the top of the controller I have declared the used classes:
public $uses = array(
When I call the function via
I get the following error:
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 ‘myFunction’ at line 1 [CORE/cake/libs/model/datasources/dbo_source.php, line 681]
In the class ‘Team’ there are declarations for $belongsTo and for $hasAndBelongsToMany. If both of these are either removed, or set to an empty array, the error disappears and the function executes.
Also if the order of $uses array is changed, so that ‘JobUser’ is before ‘Team’, again the error disappears and the function executes.
At this point I am at a loss as to where else to look or what to check. Any guidance would be greatly appreciated,