yii2.0 Framework Database operations Activityquery methods in class

Source: Internet
Author: User
Activityquery

path:vender/yiisoft/yii2/db/activequery.php Description

Activequery represents a DB query associated with an active Record class, which may be a normal query, or it may be used for associative content; Normal activequery instances of representations

Typically created through Activerecord::find () and Activerecord::findbysql (), you can retrieve the results of a query by one () returns the first line of content that is queried from the database, and all () returns the results of all queries; COUNT () returns the number of records queried, sum () returns the sum value of a pure numeric column, average () returns the average of a pure numeric column, Min () returns the minimum value of a pure numeric column, and Max () returns the maximum value of a pure numeric column; scalar () returns the value of the first column in the first row of the query Lumn () returns the first column of the query, and exists () queries whether the content exists in the query results;

Examples of Use methods: Activerecord::find ()->one ()

Because Activequery inherits from query, we can also use the query class method: with () to develop the relational table used by this query; Joinwith () reuses a relational query definition and adds it to another query; Indexby () Returns the column that was made in the query result; Asarray () returns the query result as an array;

Use method: Activerecord::find ()->asarray ()->one () returns the first element of the result array as an array returns the associated content query

Created by Activerecord::hasone () or Activerecord::hasmany (), the association activequery represents the relationship between two active Record classes;

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.