Home > Backend Development > PHP Tutorial > Query method of yii database, yii database method_PHP tutorial

Query method of yii database, yii database method_PHP tutorial

WBOY
Release: 2016-07-12 09:02:19
Original
906 people have browsed it

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)

www.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. ...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template