Use of aliases in php namespaces

Source: Internet
Author: User
When using an alias in the php namespace, MYSQL can take an alias for fields and table names, for example:

1) SELECT a. username, a. order FROM orders AS

Inner join user AS B ON a. username = B. username; -- alias for the table

2) select count (goods_id) AS totalGoods FROM tdb_goods; -- alias for the field

1) alias is used for the table, which avoids ambiguity. if the condition after ON is changed to username = username, it is clear that

An error will be reported. of course, you can change it to order. username = uer. uername, but it is not easy to get an alias.

From 2) we can see that taking an alias for a field can make the meaning clearer and improve readability.

In the PHP namespace, you can also take an alias for the namespace identifier. the benefit is that the alias in MYSQL is

The same.


Declare the namespaces root \ sub1 and root \ sub2;

Running result:

Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

Related Article

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: 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.