php - Cakephp Custom Datasource Save/Update -


using latest cakephp build 1.3.6.

i'm writing custom datasource external rest api. i've got read functionality working beautifully. i'm struggling model::save & model::create.

according documentation, below methods must implemented (see below , notice not mention calculate). these implemented. however, getting "fatal error: call undefined method apisource::calculate()". implemented apisource::calculate() method.

describe($model) listsources() @ least 1 of: create($model, $fields = array(), $values = array()) read($model, $querydata = array()) update($model, $fields = array(), $values = array()) delete($model, $id = null)

public function calculate(&$model, $func, $params = array())  {   pr($model->data); // post data   pr($func); // count   pr($params); // empty   return '__'.$func; // returning __count;  } 

if make call model

$this->save($this->data) 

it calling calculate, none of other implemented methods. expect either call apisource::create() or apisource::update()

any thoughts or suggustions?

leo, tipped me in right direction. answer in model using custom datasource. model must define _schema.

class user extends appmodel {       public $name = 'user';      public $usedbconfig = 'cvs';      public $usetable = false;      public $_schema = array(         'firstname' => array(             'type' => 'string',             'length' => 30         ),         'lastname' => array(             'type' => 'string',             'length' => 30         ),         'email' => array(             'type' => 'string',             'length' => 50         ),         'password' =>  array(             'type' => 'string',             'length' => 20         )         );  ... } 

i'm guessing if implement describe() method in custom datasource solve problem too. in case needed predefined authorize saves and/or creation.


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -