カスタム データソースを使用して Web サービスを利用しています。作成、読み取り、更新はうまく機能しますが、削除は機能しません。
コントローラーで delete メソッドを呼び出すコードを次に示します。
public function delete($id){
$this->autoRender = false;
debug($this->Article->delete($id));
}
そして、ここに私のデータソースのコード
public function delete(Model $Model, $id = null) {
echo "Display a message if this method is 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;
}
しかし、アイテムを削除したいときは、debug();
表示false
. 他の表示はありません。delete メソッドが正しく呼び出されない理由がわかりません。私のコードに何か問題がありますか?
ありがとう