我们有一个yii1
站点,其中包含大量数据库查询,从某些安全角度来看,我们希望以加密形式存储数据,并希望在使用前解密。
我正在使用beforeSave和afterFind方法,但网格不起作用。 以下是我的代码:
public function beforeSave() {
$this->name = CommonFunctions::encodeString($this->name);
$this->currency_symbol = CommonFunctions::encodeString($this->currency_symbol);
$this->is_base_currency = CommonFunctions::encodeString($this->is_base_currency);
$this->exchange_rate = CommonFunctions::encodeString($this->exchange_rate);
return parent::beforeSave();
}
protected function afterFind() {
$this->name = CommonFunctions::decodeString($this->name);
$this->currency_symbol = CommonFunctions::decodeString($this->currency_symbol);
$this->is_base_currency = CommonFunctions::decodeString($this->is_base_currency);
$this->exchange_rate = CommonFunctions::decodeString($this->exchange_rate);
parent::afterFind();
}