php - Custom delete method doesn't call in custom datasource -
i'm using custom datasource consume webservice. create, read , update work delete doesn't works.
here code calling delete method in controller.
public function delete($id){ $this->autorender = false; debug($this->article->delete($id)); }
and here code in datasource
public function delete(model $model, $id = null) { echo "display message if method called"; $json = $this->http->post(cakesession::read('site.url') . '/webservice/delete/', array( 'id' => $id, 'apikey' => $this->config['apikey'], 'model' => $model->name )); $res = json_decode($json, true); if (is_null($res)) { $error = json_last_error(); throw new cakeexception($error); } return true; }
but when want delete item, debug();
display false
. have no other displays. don't understand why delete method isn't called correctly. there wrong in code ?
thanks
let's check: you're passing parameter method:
$this->article->delete($id)
according method created, first parameter, required, model
. second $id
:
public function delete(model $model, $id = null)
during method want use both parameters. here:
'id' => $id
and here:
'model' => $model->name
based on this, need review how method called. btw, if want override delete()
method, according book, need this: delete(int $id = null, boolean $cascade = true)
.
Comments
Post a Comment