1

我正在尝试为将更新特定建筑物记录的应用程序添加 API 调用。这是它的简单版本,但它似乎没有做任何事情(包括错误)。我错过了什么?任何想法表示赞赏!

调用 API 方法的 url: http://example.com/api/request/UpdateBuilding/<token>/156/The%20Atticus%Building/120%20Finch%20Street%20Monroeville/50830

方法源代码:

private function UpdateBuilding() {     
    $buildingId=@$this->params['pass'][2];
    $name=@$this -> params['pass'][3];
    $address=@$this -> params['pass'][4];
    $zip=@$this -> params['pass'][5];

    $this->data=array(
        "id"=>$buildingId,
        "name"=>$name,
        "address"=>$address,
        "zip_code"=>$zip
    );

    $this->Building->save($this->data);
}
4

1 回答 1

0

感谢此线程中的评论:http://stackoverflow.com/questions/2314632/save-returning-false-but-with-no-error-in-cakephp,我曾经debug($this->ModelName->invalidFields()); 确定缺少两个字段。很高兴知道!

于 2012-11-15T19:19:09.020 回答