Any One Can Help With This?

public function beforeFind() {

     $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.

If at all, I’d rather specify a select statement in the models’ defaultScope() method. Dunno if that’ll help you, though.

same error, can u plz show me a demo code? 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.

do u mean code like this?

public function defaultScope(){


    return array(


            'select'=>array('*', new CDbExpression('aes_decrypt(fieldA, "' . $this->key . '") as fieldA_de'))


            );


    


}

plz correct me if I made any mistake here,

looks working now, thank u very much.