Reusing a result set


show more Reusing a result set provides you with in-depth training on Developer. Taught by David Powers as part of the Accessing Databases with Object-Oriented PHP show less
please wait ...

Reusing a result set

Sometimes you need to reuse a result set. There are several ways of doing so. Chosing the right one, depends on the database system you're using. This is pdo_reuse.php which you can find in the chapter 04_04_04 folder of the exercise files, along with the other files used in this video. The try block at the top of the page, submits a select query, and stores the result set in result. In the body of the page, there's a while loop on lines 27 to 29, that uses the fetch column method to get the values from the first column, and displays an unordered list of links.

Further down on line 33 to 36, there's another while loop, that uses the same result object, to display a definition list. So let's load this in a browser to see what happens. The unordered list is displayed correctly, but the definition list, isn't. This is because a result set uses an internal cursor to keep track of the next row. Displaying the unordered list puts the cursor at the end of the result set. And before trying ...

Reusing a result set
Video duration: 7m 53s 3h 47m Intermediate

Viewers:

Reusing a result set provides you with in-depth training on Developer. Taught by David Powers as part of the Accessing Databases with Object-Oriented PHP

Subject:
Developer
Software:
PHP
Author:
please wait ...