Yii Framework Forum: how can use "findAllByAttributes" - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

how can use "findAllByAttributes" Rate Topic: ***-- 2 Votes

#1 User is offline   konichiwa 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 23
  • Joined: 03-August 09

Posted 10 August 2009 - 09:53 PM

I have code to find a row with a column that I knew the value:


 $userid = Yii::app()->user->id;
        
		$models=useremail::model()->findAllByAttributes('ue_userid',$userid);
        echo $models->ue_id;


but I have error mess:
Invalid argument supplied for foreach()


??? what wrong ?
0

#2 User is offline   konichiwa 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 23
  • Joined: 03-August 09

Posted 10 August 2009 - 10:16 PM

I solved it :) I'm wrong with statement:
it must be:

     findByAttributes(array('username'=>$this->username));

0

#3 User is offline   Nam Gi VU 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 6
  • Joined: 09-August 11

Posted 21 September 2011 - 10:48 PM

*
POPULAR

Hi,
My favored usage is as below
$found = YourModelClass::model()->findAllByAttributes(
	array(),
	$condition  = 'columnNameInDb = :someVarName AND columnNameInDb02 > :someVarName02',
	$params     = array(
		':someVarName' => $someVarNameValue, 
		':someVarName02' => $someVarNameValue02,
	)
);


Hope it helps,
Nam.
6

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

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