Search code examples
phpyii

how to count null field from database in index page in yii php tag


I want to count readdate which must be null in table. I want to fire code in html, there is one table which contains fields like id, storeid, message, readdate, entrydate. If readdate is null then I want to count it and display those counts.

<html>
   <div class="orange-count">
      <?php
         echo $unread_recommendation = Storenotification::model()->count("id='" . Yii::app()->session['id'] . "' AND readdate='null' ");
       ?>
   </div>
</html>

Solution

  • Sql command for NULL count

    select count(*) from table where column IS NULL;
    

    Change it according to your framework.