Yii about Find FindAll finds out the method of the field that was developed, Yiifindall
Always known
// to find out is an object Modelname::model (), FindALL () // Find an array of object collections
How to find the data for the fields I need, not all of the fields
That's what I did before.
$criteria New Cdbcriteria; $criteria->select = ' username,id,email '; $criteria->order = ' id DESC '; $users $criteria );
Backstage to see others have so written, found that they are how ignorant
$users = Modelname::model ()->findall (array( ' select ' = =array (' username ', ' id ', ' email '), ' order ' = ' id DESC ', ') ;
After the test, I found that it can be used, so find can do the same.
$user = Modelname::model ()->find (array( ' select ' = =array(' username ') , ' id ', ' email '), ' order ' = ' id DESC ', ' condition ' = ' id= '. $id,));
Of course, it's not safe to do this, but it's also possible to change to the following method
$users $this->user->find (array( ' select ' = =array(' id ', ' Username ', ' email '), ' order ' = ' id DESC ', ' condition ' = ' state=:state and Id=:id ', array (': state ' = ' 1 ', ': id ' = ' 2 '),));
It's also possible to use the FindAll test, the conclusion
This method can be very convenient to obtain the required data, of course, the need for paging or new Cdbcriteria
Yii Framework, $retrievedProject =project::model ()->findall (); How to Output?
$retrievedProject =project::model ()->findall ();
foreach ($retrievedProject as $v) {
echo $v->attributes[' title '];
}
Yii Query Statement notation
Write this:
$db = new Cdbcriteria ();
$db->addincondition (' id ', array (+/-));
$newstypelist =newstype::model ()->findall ($DB);
http://www.bkjia.com/PHPjc/874529.html www.bkjia.com true http://www.bkjia.com/PHPjc/874529.html techarticle Yii about Find FindAll method of finding out the fields that are developed, Yiifindall is known Modelname::model ()-Find ()//Find an Object Modelname::model ()-FindAll () Find out the ...