How do I call already created custom actions in my model from the controller
It seems to be working fine in cakephp1.x version. But when I try to upgrade it into cakphp2.10 methods are not working showing below error
Database Error Error: SQLSTATE[42000]: Syntax error or access violation: 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 'getChildCategory' at line 1
My code is
Controller call
$this->loadModel('Category');
$childCategories = $this->Category->getChildCategory();
Model function
App::uses('AppModel', 'Model');
class Category extends AppModel {
var $name = 'Category';
var $displayField = 'Category_cname';
public function getChildCategory()
{
$Db = ConnectionManager::getDataSource($this->useDbConfig);
$cattbl = $Db->fullTableName('categories');
$dat = $this->query("select yt.cname,yt.id
from $cattbl yt
where not exists (select null from $cattbl where parent_id = yt.id) LIMIT 0,10");
return $dat;
}
}
Any help much appreciated!