hworg
29 Oct 2009, 4:55 PM
Hi,
I'm having trouble with direct which I'm not sure how to fix. I have a class with the remotable doctag set, but when I call it the response says shows an exception saying like below -
{"type":"exception","tid":2,"message":"Call to undefined or unallowed method: add_category on class category","where":"#0 C:\\webserver\\htdocs\\generation\\lib\\direct\\ExtDirect\\Router.php(62): ExtDirect_Router->rpc(Object(stdClass))\n#1 C:\\webserver\\htdocs\\generation\\lib\\direct\\router.php(19): ExtDirect_Router->dispatch()\n#2 {main}"}The php code is
require_once(FILE_ROOT . 'core/database/model.php');
class category extends DatabaseTable {
public $relationships = array();
public function __construct() {
parent::__construct(array(
'id',
'title'
));
}
/**
* @remotable
*/
public function add_category($newcat) {
$cat = new category();
$cat->title = Database::sanitise(&$newcat);
$cat->commit();
return true;
}
/**
* @remotable
*/
public function get_categories() {
$results = $this->select_array();
return array('total'=>count($results), 'results'=>$results);
}
}
The get_categories function works fine, but the add_category function reports that exceptions. Both functions are callable from PHP, so I'm rather confused.
Any thoughts?
I'm having trouble with direct which I'm not sure how to fix. I have a class with the remotable doctag set, but when I call it the response says shows an exception saying like below -
{"type":"exception","tid":2,"message":"Call to undefined or unallowed method: add_category on class category","where":"#0 C:\\webserver\\htdocs\\generation\\lib\\direct\\ExtDirect\\Router.php(62): ExtDirect_Router->rpc(Object(stdClass))\n#1 C:\\webserver\\htdocs\\generation\\lib\\direct\\router.php(19): ExtDirect_Router->dispatch()\n#2 {main}"}The php code is
require_once(FILE_ROOT . 'core/database/model.php');
class category extends DatabaseTable {
public $relationships = array();
public function __construct() {
parent::__construct(array(
'id',
'title'
));
}
/**
* @remotable
*/
public function add_category($newcat) {
$cat = new category();
$cat->title = Database::sanitise(&$newcat);
$cat->commit();
return true;
}
/**
* @remotable
*/
public function get_categories() {
$results = $this->select_array();
return array('total'=>count($results), 'results'=>$results);
}
}
The get_categories function works fine, but the add_category function reports that exceptions. Both functions are callable from PHP, so I'm rather confused.
Any thoughts?