如何在CDbCriteria(yii)中编写以下查询?

$query="select U.MUID,U.UID,U.PWD,U.UNAME,U.EMAILID,U.GROUPID,U.TRANSDATE,U.ACTIVEYN,
            G.GRP_DESC,G.FACTORY_SETTING from mas_users U
            inner join user_group G on U.GROUPID=G.GROUPID
            where U.ACTIVEYN=1 and U.GROUPID  <> 6 AND MUID <>1729 and MUID <>1727 and U.GROUPID <> 100000 order by U.GROUPID";

Please help me to write the query as CDBcrieteria in yii

have a look at this

this

this is the best way of extarting data from table joins

You first should read all the content present in yii study guide which is very helpful to you during development here itself i will write the solution but it will diminish your learning ability instead of that i request you to read this content from yii study guide.

suggestion : learn about scopes clearly.

please click the given link

relational AR

I hope this solution helps you:

    $array = Yii::app()->db->createCommand()
        ->select('U.MUID,U.UID,U.PWD,U.UNAME,U.EMAILID,U.GROUPID,U.TRANSDATE,U.ACTIVEYN, G.GRP_DESC,G.FACTORY_SETTING from mas_users U')
        ->from('mas_users U')
        ->join('user_group G','U.GROUPID=G.GROUPID')
        ->compare('U.ACTIVEYN=:ain')
        ->andWhere('U.GROUPID  <>:gid')
        ->addNotInCondition('MUID', array(1729,1727))
        ->addNotInCondition('U.GROUPID', array(6,100000))
        ->order('U.GROUPID')
        ->bindValue(':ain',1,PDO::PARAM_INT)
        ->bindValue(':gid',6,PDO::PARAM_INT)
        ->queryAll();