How to Use alias for database operations of thinkPHP?

Source: Internet
Author: User
How to Use alias for database operations of thinkPHP? Parameter types supported by coherent operations
Alias is used to define an alias string for the current data table.

How to use the thinkPHP operation method alias, do not write the original SQL statement
Is alias missing in thinkPHP development documentation? My development document is thinkPHP3.1.2.


Reply to discussion (solution)

Please comply with the CSDN user code of conduct and shall not violate national laws and regulations.

Http://www.thinkphp1.cn/simple/quickstart_4.html

Alias is used to set the alias of the current data table to facilitate other consistent operations, such as the join method. Example: $ Model = M ('user'); $ Model-> alias ('A')-> join ('_ DEPT _ B ON B. user_id =. ID')-> select (); the final SQL statement is similar to: SELECT * FROM think_user a inner join think_dept B ON B. user_id =. id
Http://document.thinkphp1.cn/manual_3_2.html#alias

Alias is used to set the alias of the current data table to facilitate other consistent operations, such as the join method. Example: $ Model = M ('user'); $ Model-> alias ('A')-> join ('_ DEPT _ B ON B. user_id =. ID')-> select (); the final SQL statement is similar to: SELECT * FROM think_user a inner join think_dept B ON B. user_id =. id
Http://document.thinkphp1.cn/manual_3_2.html#alias
That is similar to this native SQL
Select count (*) from (select * from user where userId> 10) as a; alias a for a query result set and count
How should I write thinkPHP?

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.