Understanding about $ query = mysql_query ($ query); what type of value is returned

Source: Internet
Author: User

Understanding about $ query = mysql_query ($ query); what type of value is returned

Today, I saw a post on the csdn Forum about $ query = mysql_query ($ query); what type of value is returned, and thought that the returned value is an array type, after debugging, I found that it is not an array type but a resource type. Below is a demo.Code

<? Phprequire_once ("phpmysql. PHP "); // introduces the database MySQL operation class phpmysql. PHP File $ SQL = "select * From hello007"; // set the SQL query statement $ query = $ db-> query ($ SQL); // call phpmysql. var_dump ($ query); // var_dump () is used to print information about a variable. The output structure is resource (4) of type (MySQL result) echo is_resource ($ query); // is_resource () is used to determine whether the output result of the variable type is 1 // $ ROW = $ db-> fetch_array ($ query ); //?>

The debugging result is as follows:

Resource (4) of type (MySQL result) 1

View the PHP manual, search for "Resource Type", and check that the method named MySQL result contains mysql_query (). Therefore, the value returned by this method is the resource type. In fact, from this sentence $ ROW = $ db-> fetch_array ($ query); you can also determine that the returned value is not of the array type, because this sentence stores the resource type by array type!

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.