yii-Model-Criteria Lookup database methodCriteri find Yii Search method yii lookup Yii Lookup Database
Data Model Search methods:[HTML] View Plain copy print? Public function search () { // Warning: please modify the following code to remove attributes that // should not be searched. $criteria =new cdbcriteria; $criteria-> Compare (' id ', $this->id); $criteria->compare (' title ', $this->title, true); //supports Fuzzy Lookup $criteria->compare (' content ', $this->content,true); //support for Fuzzy Lookup $criteria- >compare (' type ', $this->type); $criteria->compare (' user ', $This->user,true); // Support for Fuzzy Lookup $criteria->compare (' status ', $this->status); $criteria->compare (' Create_data ', $this->create_data,true); // Support for Fuzzy Lookup return new cactivedataprovider ($this, Array ( ' criteria ' => $criteria, ' pagination ' =>array ( ' pageSize ' =>50, ), ); }
Define comparison operations [HTML] view plain copy print? $criteria->compare (' create_time ', ' <= '. $this->endtime),//creation morning is less than or equal to the specified time
Define the field to find [HTML] view plain copy print? The result of the lookup $criteria->select = ' id,title,content,author,status,createtime ',//can also be defined in one of the following ways $criteria->select = AR Ray (' id ', ' title ', ' content ', ' author ', ' Status ', ' Createtime '),
Define fill in Find conditions [HTML] view plain copy print?//define Conditions $criteria->select = ' Status=1 ', //Add match $criteria->compare (' title ', $this->title,true), //Add condition $condition can be an array or a string, and can omit $criteria->addcondition ($condition, ' and ' , //Add in Condition $column for field name $criteria->addincondition (string $column, array $values, string $operator = ' and ') //Add notin condition $criteria-> Addnotincondition (string $column, array $values, string $operator = ' and ') / /Add like condition $criteria->addsearchcondition (string $column, string $keyword), //Add between Condition $criteria->addbetweencondition (string $column, string $ valuestart, string $valueEnd, string $operator = ' and '),
Join table Query [HTML] view plain copy print? $criteria->join = ' Left join users on Users.id=authorid ',
Order query result sort [HTML] view plain copy print? $criteria->order = ' Createtime DESC ',
Group result grouping [HTML] view plain copy print? $criteria->group = ' ProjectID, Teamid ',
Having filtered group result grouping quantity [HTML] view plain copy print? $criteria->having = ' SUM (revenue) <50000 ',