Yii database query method

Source: Internet
Author: User
: This article describes how to query the yii Database. For more information about PHP tutorials, see. 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-> c 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.

The above introduces the yii database query method, including the content, hope to be helpful to friends interested in PHP tutorials.

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.