Yii database query method, yii database method
This article describes the query method of yii database with examples. Share it with everyone for your reference, the details are as follows:
Here are two query methods. One is to query directly, and the other is to query using criteria.
Copy code The code is as follows: $user=User::model();
1. Direct inquiry:
$arr=array(
"select"=>"username,password,email", //要查询的字段
"condition"=>"username like '%6'", //查询条件
"order"=>"id desc",
"limit"=>5,
"offset"=>1,
);
$info=$user->findAll($arr);
Copy after login
2. Use criteria:
$criteria=new CDbCriteria();
$criteria->select="username,password,email";
$criteria->condition="username like '%1'";
$criteria->limit=5;
$criteria->order="id desc";
$criteria->offset=1;
$info=$user->findAll($criteria);
Copy after login
I hope this article will be helpful to everyone’s PHP program design based on the yii framework.
Articles you may be interested in:
- Yii Getting Started Tutorial: Directory Structure, Entry File and Routing Settings
- Yii Getting Started Tutorial: Yii Installation and Hello World
- Yii PHP Framework practical introductory tutorial (detailed introduction)
- Yii Query Builder (Query Builder) usage example tutorial
- YII method of using url component to beautify management
- yii Methods to remove asterisks in required fields
- Methods to implement batch deletion of CGridView in Yii
- Yii permission control methods (three methods)
- Summary of YiiFramework entry knowledge points (Picture and text tutorial)
http://www.bkjia.com/PHPjc/1085890.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1085890.htmlTechArticleQuery method of yii database, yii database method This article describes the query method of yii database with examples. Share it with everyone for your reference, the details are as follows: Here are two query methods. ...