Note that there are some explanatory texts on larger screens.

plurals
  1. POIS NOT NULL not working in Yii Active Record
    text
    copied!<p>I am trying something like this:</p> <pre><code>public function search() { $criteria = new CDbCriteria; $criteria-&gt;compare('user_details_id', $this-&gt;user_details_id); $criteria-&gt;compare('user_type_id', $this-&gt;user_type_id); $criteria-&gt;compare('customer_basics_id', $this-&gt;customer_basics_id); $criteria-&gt;compare('user_address_id', $this-&gt;user_address_id); $criteria-&gt;compare('user_city_id', $this-&gt;user_city_id); $criteria-&gt;compare('is_active', $this-&gt;is_active); $criteria-&gt;compare('create_dttm', $this-&gt;create_dttm, true); $criteria-&gt;compare('update_dttm', $this-&gt;update_dttm, true); // if condition is working if (isset($_GET['ulip'])) { $criteria-&gt;addCondition( "customer_basics_id=" . CustomerBasics::getCustomerBasicsId(Yii::app()-&gt;session['user_id']), "AND" ); $criteria-&gt;addCondition("user_city_id IS NULL"); // else condition is working } else { $criteria-&gt;addCondition( "customer_basics_id=" . CustomerBasics::getCustomerBasicsId(Yii::app()-&gt;session['user_id']), "AND" ); $criteria-&gt;addCondition("user_city_id IS NOT NULL"); } return new CActiveDataProvider($this, array( 'criteria' =&gt; $criteria, 'pagination' =&gt; array( 'pageSize' =&gt; 10, ), )); } </code></pre> <p>Here the issue is <code>if</code> condition is working fine and showing results according to the condition but else part is not working and it returns nothing. I think <code>IS NOT NULL</code> is not working here. </p> <p>What is the issue ?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload