$this->dbCriteria->select .= ' ,aes_decrypt(fieldA, "string") as fieldA_de';
}//want use this to auto get de value via db connection,
it's working good when I run className::model()->find();
but it's not working when I run className::mode()->with('relationName')->find();
//ERROR DETAIL
Active record "ClassName" is trying to select an invalid column "aes_decrypt(fieldA". Note, the column must exist in the table or be an expression with alias.
framework1113/db/ar/CActiveFinder.php(917)
here is all I found, can anyone know how to fix it? or anything I missed? thx.
Hm, can you show me what you have in your defaultScope() method? I just checked back with the documentation and it looks like CDbCriteria.select could be an array as well. In that case, it’ll be simple: Use CDbExpression to decrypt the field in question.
public function defaultScope(){
return array(
'select'=>array('*', new CDbExpression('aes_decrypt(fieldA, "' . $this->key . '") as fieldA_de'))
);
}