为什么 saveField() 不保存 CakePHP 2.x 中的记录?

Why is saveField() not saving the record in CakePHP 2.x?

我正在使用 cakephp 2.6.7。

在Model/ResellerAccount中:

<?php

class ResellerAccount extends AppModel {

    var $name = "resellerAccounts";           
}

?>

我的 table 名字是 reseller_accounts。

在控制器中:

function moneySentToreseller($id = null) {
    if ($id) {
        $this->loadModel('ResellerAccount');

        $this->ResellerAccount->id = $id;
        $this->ResellerAccount->saveField("ResellerAccount.status", "sent");
        $msg = '
            <div class="alert alert-success">
                <button type="button" class="close" data-dismiss="alert">&times;</button>
                <strong> Money send to this reseller succeesfully </strong>
           </div>';
        $this->Session->setFlash($msg);
    }
    return $this->redirect($this->referer());
}

但是该字段没有被更新。我的代码出了什么问题?

根据 documentation:

When using this method, $fieldName should only contain the name of the field, not the name of the model and field.

尝试按如下方式保存:

    $this->ResellerAccount->saveField("status", "sent");

还要注意您的模型名称:

    var $name = "resellerAccounts";           

应该是

    public $name = "ResellerAccount";