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!