[SOLVED] - AR: SELECT IN

Hello folks,

I have the following SQL-Statement

[indent]


SELECT * FROM produkte WHERE produkte.id IN (SELECT pid FROM suche WHERE pname LIKE '%album%')

[/indent]

using PHP admin, it works fine.

For my whole project I use AR.

Now I thought, I can use AR in a simple way:

[indent]




$crit = new CDbCriteria();

$prod = new CProdukte();	// the model class

$crit->condition = "id IN (SELECT pid FROM suche WHERE pname LIKE '%album%'";

$rows = $prod->findAll($crit);



[/indent]

But the error code is:

[indent]


Attempt to assign property of non-object

[/indent]Ideas & discussion are welcome.

Scryii

[indent] [/indent]

Look at CDbExpression

The code looks correct, are you sure the error is in this lines?

As it is, this code works correctly to me.

tsss tsss tssss …

Simple, if you know.

I always used the $crit variable.

I only had to


unset($crit);

it - and it works.

Thanx.

Scryii