Yii1.1 查询总结

1、查询数组

$select = 'id';
$where = [];
$info = Yii::app()->db->createCommand()
        ->select($select)
        ->from('ueb_product.ueb_ebay_online_listing')
        ->where($where)
        ->queryAll();

2、去重查询

public static function getUniquePositivefeedbackpercent(){
        $self = new self();
        $result = $self::model()->findAll(array(
            'select'=>array('distinct positive_feedback_percent','id'),
            'order'=>'id ASC',
        ));
        return $result;
    }

3、去重、排序

$result = Yii::app()->db->createCommand()
            ->selectDistinct('positive_feedback_percent')
            ->from($self->tableName())
            ->order('positive_feedback_percent asc')
            ->queryAll();

4、查询,在模型层中查询

$data= $this->dbConnection->createCommand()
                    ->select('*')
                    ->from(self::tableName())
                    ->where("status = 1")
                    ->order($order)
                    ->queryAll();

你可能感兴趣的:(Yii1.1)