Php Yii使用createcommand从数据库检索数据,并使用变量对其进行计数

Php Yii使用createcommand从数据库检索数据,并使用变量对其进行计数,php,yii,Php,Yii,创建了一个如下所示的查询 <?php $notf = $not->id; $currDate = date('Y-m-d H:i:s'); $list=Yii::app()->db->createCommand("select id from tbl where start_dt <= '$currDate' and end_dt >= '$currDate'"); $res = $list->qu

创建了一个如下所示的查询

    <?php
      $notf = $not->id;
      $currDate = date('Y-m-d H:i:s');
      $list=Yii::app()->db->createCommand("select id from tbl where start_dt <= '$currDate' and end_dt >= '$currDate'");
      $res = $list->queryColumn();
      // Code for get the value of the column...
    ?>
我在php中使用了$row=mysql\u fetch\u assoc'$qry',然后使用$data=$row['field\u name']来获取数据。我在Yii应该做什么


我是Yii新手。

您可能需要使用queryScalar而不是queryColumnTry queryRow和$row['fieldName',或者使用queryScalar。当您坐“Tall”时,您是指计数,对吗?如果是,为什么不将查询更改为选择count*。。。?
<?php if(!$variable === $notf){ ?>