Yii Framework Forum: [SOLVED] - AR: SELECT IN - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

[SOLVED] - AR: SELECT IN Last challenge to finish my project R1 :-) Rate Topic: -----

#1 User is offline   Scryii 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 54
  • Joined: 30-September 10
  • Location:Germany, Munich

Posted 28 January 2011 - 04:04 PM

Hello folks,

I have the following SQL-Statement
SELECT * FROM produkte WHERE produkte.id IN (SELECT pid FROM suche WHERE pname LIKE '%album%')


using PHP admin, it works fine.

For my whole project I use AR.
Now I thought, I can use AR in a simple way:
$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);


But the error code is:
Attempt to assign property of non-object


Ideas & discussion are welcome.

Scryii

0

#2 User is offline   sergeymorkovkin 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 98
  • Joined: 15-December 08

Posted 29 January 2011 - 03:35 AM

Look at CDbExpression
Pro web developer, open for new projects, click for portfolio.
0

#3 User is offline   zaccaria 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 2,232
  • Joined: 04-October 09
  • Location:Moscow

Posted 29 January 2011 - 03:49 AM

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

As it is, this code works correctly to me.
0

#4 User is offline   Scryii 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 54
  • Joined: 30-September 10
  • Location:Germany, Munich

Posted 29 January 2011 - 11:34 AM

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
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users