我试图在我的模型的 beforeSave 方法中加密一些数据。但它没有被保存。
$currentBalance = $this->find("all", array(
"fields" => array(
"SUM(base_amount) as 'CurrentBalance'"
),
"conditions" => array(
"Payment.user_id" => $this->data["Payment"]["user_id"]
)
));
$this->log($this->data["Payment"]);
$this->log(Configure::read("Security.salt"));
$this->log(Security::cipher(implode("|", $this->data["Payment"]), Configure::read("Security.cipherSeed")));
$this->set("balance", $currentBalance[0][0]["CurrentBalance"] + $this->data["Payment"]["base_amount"]);
$this->set("balance_checksum", Security::cipher(implode("|", $this->data["Payment"]), Configure::read("Security.salt")));
如果我查看日志文件,我会得到某种加密数据,但都是胡言乱语。
虽然在数据库中,但我一无所获。
如果我用一个简单的字符串替换密码函数说“123”......那将被正确保存。
我已确保数据库连接是 utf8 编码的,并且数据库中的字段具有 utf8 排序规则。
对此的任何指示都会很棒
谢谢