yii 只查詢指定字段

                $cri = new CDBcriteria();
                $cri->addCondition( ' hid = '.$hid.' ' );
                $cri->select = 'id,property';
                $costMoney = Cost::model()->find($cri);

這種方法是查找出指定的字段的值,可是因爲是對象,因此其餘字段值都被補成空!php

沒法達到要求sql

要下面的方法app

 $sql = " select ".$fields." from ysh_cost where hid = " . $hid;
                $costMoney = Yii::app()->db->createCommand($sql)->query();

顯示結果spa

Array
(
    [0] => Array
        (
            [property] => 12
            [stop] => 12
        )

)
相關文章
相關標籤/搜索