Is the result set returned by mysqli an object? Why?

Source: Internet
Author: User
$ 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

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