From the course: PHP: Accessing Databases with PDO and MySQLi

Unlock the full course today

Join today to access over 22,400 courses taught by industry experts or purchase this course individually.

Using real_query()

Using real_query() - PHP Tutorial

From the course: PHP: Accessing Databases with PDO and MySQLi

Start my 1-month free trial

Using real_query()

In addition to the query method, MySQLi has the rather oddly named real query method. With the select statement, the query method executes the query and returns a MySQLi result object, with the result set stored in PHP memory, ready for use. The real query method on the other hand, simply submits the query. You need to retrieve the result set separately. This is mysqli_real_query.php, which you can find in the chapter 7 07_02 folder of the Exercise Files. And we'll use this to experiment with the differences between query and real query. At the top of the page, there are two select queries that are executed one after the other using the query method. And the first result is stored as result. The second one as result2. Down in the page, two while loops display the different results. And if we load that page into a browser, we can see the two different result sets being displayed. So, let's change the first one to real query. So we need to scroll up, and then on line five, we'll change…

Contents