Home>

Data model search method:

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);//Support fuzzy search
  $criteria->compare ("content", $this->content, true);//Support fuzzy search
  $criteria->compare ("type", $this-&type;type);
  $criteria->compare ("user", $this->user, true);//Support fuzzy search
  $criteria->compare ("status", $this->status);
  $criteria->compare ("create_data", $this->create_data, true);//Support fuzzy search
  return new cactivedataprovider ($this, array (
    "criteria" =>$criteria,    "pagination" =>array (
      "pagesize" =>50,    ),  ));
}

Define the comparison operation:

$criteria->compare ("create_time", "<=". $this->endtime),//Create morning time is less than or equal to the specified time

Define the fields to find:

//Search results
$criteria->select="id, title, content, author, status, createtime",//Can also be defined in one of the following ways
$criteria->select=array ("id", "title", "content", "author", "status", "createtime"),

Define search conditions:

//define conditions
$criteria->select="status=1",//Add a match
$criteria->compare ("title", $this->title, true),//Add condition $condition can be an array,Can also be a string,and can be omitted
$criteria->addcondition ($condition, "and"),//Add in condition $column as field name
$criteria->addincondition (string $column, array $values, string $operator="and")
//Add the 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 join table query

$criteria->join="left join users on users.id=authorid",

order query results sort:

$criteria->order="createtime desc",

group result grouping:

$criteria->group="projectid, teamid",

having filtering grouping results grouping number:

$criteria->having="sum (revenue)<50000",
php
  • Previous Android based on ViewDragHelper imitate QQ50 sliding interface effect
  • Next JavaScript-DOM operation-Windowdocument object