Yii database query method, yii database method _ PHP Tutorial

Source: Internet
Author: User
Yii database query method, yii database method. Yii database query method, yii database method this article describes the yii database query method. For your reference, here are two query methods. Yii database query method, yii database method

This article describes how to query the yii database. We will share this with you for your reference. The details are as follows:

Two query methods are described here. One is direct query, and the other is to use criteria for query.
The code is as follows: $ user = User: model ();

1. direct query:

$ Arr = array ("select" => "username, password, email", // the field to be queried "condition" => "username like '% 6 '", // query condition "order" => "id desc", "limit" => 5, "offset" => 1 ,); $ info = $ user-> findAll ($ arr );

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);

I hope this article will help you design PHP programs based on the yii Framework.

Articles you may be interested in:
  • Directory structure, entry file, and route settings in Yii Getting Started Tutorial
  • Yii installation and hello world
  • Yii PHP Framework practical Getting Started Tutorial (details)
  • Yii Query Builder usage example tutorial
  • How to beautify YII by using url components
  • Yii removes the star number in the required field
  • Batch delete of CGridView in Yii
  • Yii permission control methods (three methods)
  • YiiFramework knowledge point summary (graphic tutorial)

The following example describes how to query the yii database. For your reference, here are two query methods ....

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.