Hi.
I’ve got a model $User
whos email is stored encrypted in the db
beforeSave
{
$this->email = cdbexpression des_encrypt ...
}
How do I make yii automatically fetch the email as decrypted string?
Hi.
I’ve got a model $User
whos email is stored encrypted in the db
beforeSave
{
$this->email = cdbexpression des_encrypt ...
}
How do I make yii automatically fetch the email as decrypted string?
Try this:
public function defaultScope()
{
return array(
'select'=>'id, username, DES_DECRYPT(email) AS email, ...',
);
}
But you have to list all table fields, otherwise they won’t be selected.