Hi friends,
I want to convert this query (select * from tablename where columnname != NULL) into yii. Please help me.
Hi friends,
I want to convert this query (select * from tablename where columnname != NULL) into yii. Please help me.
Try
$sql="select * from tablename where columnname != NULL"
Yii::app()->db->createCommand($sql)->queryAll();
Hi
Thank you for your replay and i forget to say i want to give this condition using ‘cdbcriteria’. Can you please help me.
This is a solution with CDbCriteria if you’ve got ActiveRecords classes for your tables:
$criteria=new CDbCriteria;
$criteria->select='*'; // is also the default value so you can leave this line out
$criteria->condition='columnname != NULL';
$tableObject=tablename::model()->find($criteria);
CDbCriteria can be used in AR query methods.
Take a look at Yii Reading Record
bye
For your SQL you should be using "IS NOT NULL" in place of "!= null"
<code>$criteria->condition=‘columnname IS NOT NULL’;</code>
Hi,
I have one doubt in that ,I want to get the values in one field from the table based user_id how to fetch these values using dataprovider.
The answer is in a link already provided.