Cdbexpression In Condition

Hello everyone,

the question in simple:

how can I write in an AR expression this?

“Select * from Somewhere where md5(id)=‘oijfofjoijgodfigjsoij’” //

note that in this example is md5(id) but it’s just an example, my question is general: I mean I’d want to find a way for using CDbExpression in the condition

I Tried with:

$model=Somewhere ::model()->findByAttributes(array(new CDbExpression(‘md5(id)’)=>$id));

But I Got an "Illegal offset type" error.

Any ideas?

Hi Daniele

Check the below code

$criteria = new CDbCriteria;

$criteria->condition = 'md5(id)=‘oijfofjoijgodfigjsoij’;

$models = Somewhere::model()->findAll($criteria);

Thanks! I’ll give it a try and let you know

It Works! Thanks for the hint ;)