BoyLee 2011-03-17 13:22:05 3936次浏览 4条回复 0 0 0
$data_map = Yii::app()->db->createCommand()
		           [color=Red] ->distinct(true)[/color]
		            ->select('*')
		            ->from('sc2m_map_type')
		            ->queryAll();

报错 CDbCommand does not have a method named "distinct".

但是手册里确实有 distinct,boolean,Returns a value indicating whether SELECT DISTINCT should be used.

难道不是上面红色那样用?

  • 回复于 2011-03-17 13:25 举报

    我查了一下CDbCommand没有distinct这个方法!

  • 回复于 2011-03-17 13:28 举报

    可以这样用:

    $criteria=new CDbCriteria;
    $criteria->select = 'type';
    $criteria->condition = "username='$username'";
    $criteria->distinct = true;
    $this->findAll($criteria);
    
  • 回复于 2011-03-17 13:32 举报

    原来我一直在看属性,应该是 selectDistinct() Sets the SELECT part of the query with the DISTINCT flag turned on.

  • 回复于 2011-03-17 13:34 举报

    这次准备用DAO,不准备用AR 因为数据只是一次呈现。

您需要登录后才可以回复。登录 | 立即注册