J.K.A.
J.K.A.

Reputation: 7404

findAllByAttributes not returning any value in Yii Framework

I am passing following array in findAllByAttributes() method in my Yii Web App.

$fileArr= Array
(
    [0] => 790c83
    [1] => 402faf
    [2] => 646209
    [3] => 9332c5
)

$files = File::model()->findAllByAttributes(array('code' => $fileArr));
        print_r($fileArr);
        exit;

and when I am trying to print this its returning blank. I also tried by converting an array into string by using implode function and passed it into findAllByAttributes() method but still its not working. How can I achieve this in yii?

Upvotes: 2

Views: 1236

Answers (1)

Mihkel Viilveer
Mihkel Viilveer

Reputation: 432

Try this:

$criteria = new CDbCriteria();
$criteria->addInCondition('code', $fileArr);
$files = File::model()->findAll($criteria);
print_r($files);
exit;

Upvotes: 2

Related Questions