hi ..
i have a drop down list and i use the fuction to findall() to find all the company names is the database .
what i want to do is show only the company's with status=1
please help in what do i change to do so . how to use condition with findall() function ..
thanks a lot .
Page 1 of 1
findall with conditionin dropdown
#2
Posted 03 August 2012 - 08:34 PM
Hello,
Yii API doc and the forum's search feature are your friends
http://www.yiiframew...#findAll-detail
Now, your answer in the case of an CActiveForm:
or
(you can also see here: http://www.yiiframew...DownList-detail)
Yii API doc and the forum's search feature are your friends
http://www.yiiframew...#findAll-detail
Now, your answer in the case of an CActiveForm:
echo $form->dropDownList($model, 'countryId',
CHtml::listData(Company::model()->findAll(array('condition' => 'status = :status', 'params' => array(':status' => 1))), 'id', 'name'),
array('empty' => 'Please select a company »')
);or
echo $form->dropDownList($model, 'countryId',
CHtml::listData(Company::model()->findAll('status = 1'), 'id', 'name'),
array('empty' => 'Please select a company »')
);(you can also see here: http://www.yiiframew...DownList-detail)
#3
Posted 07 August 2012 - 08:09 AM
...or
Company::model()->findAllByAttributes( array( 'status'=>1 ) )
red
#4
Posted 07 August 2012 - 09:09 AM
Share this topic:
Page 1 of 1

Help














