$ Mysqlinewmysqli (& quot; 127.0.0.1 & quot;, & quot; root & quot;, & quot;, & quot; test & quot ;);...... $ res $ mysqli-& gt; query ($ query); $ row_cnt $ res-& gt; num_rows; number of records in the result set ...... is $ res an object? Why? (I always thought that all objects are... $ mysqli = new mysqli ("127.0.0.1", "root", "", "test ");
......
$ Res = $ mysqli-> query ($ query );
$ Row_cnt = $ res-> num_rows; // you can specify the number of records in the result set.
......
Is $ res an object? Why?
(I always thought that the object was manually new =. =)
Why is the Boolean judgment result of a result set with a record number of 0 true?
New users make everyone laugh
Reply content:
$ Mysqli = new mysqli ("127.0.0.1", "root", "", "test ");
......
$ Res = $ mysqli-> query ($ query );
$ Row_cnt = $ res-> num_rows; // you can specify the number of records in the result set.
......
Is $ res an object? Why?
(I always thought that the object was manually new =. =)
Why is the Boolean judgment result of a result set with a record number of 0 true?
New users make everyone laugh
The object depends on how the mysql driver of php is written. The object is generated in the query function, and new is not required in the script language.
Because this object exists rather than null, it is true...
mixed mysqli::query ( string $query [, int $resultmode = MYSQLI_STORE_RESULT ] )
Returns FALSE on failure. For successful SELECT, SHOW, DESCRIBE or EXPLAIN queries mysqli_query () will return a mysqli_result object. For other successful queries mysqli_query () will return TRUE.
If a request fails, FALSE is returned. If a query with a result is returned, the mysqli_result object is returned. If no result is returned, TRUE is returned.
Http://php.net/manual/en/mysqli.query.php