…If you attempt to loop through the results of a select query…a second time, it won’t work unless you reset the result object.…Doing so is trivially easy in MySQL.…This is mysqli__reuse.php which you can find in the…Chapter 5, 05_05 folder of the exercise files.…The try block at the top of the page submits…a select query, and then stores the result set as result.…In the body of the page, the while loop on lines 24 to 26 uses…the fetch_assoc method to display an ordered list of links.…
Further down, on lines 30 to 33, a second while loop…attempts to use the same result object to display a definition list.…So, if we load this into a browser, we can see what happens.…The first list is displayed but the definition list isn't.…This is because a result set uses an…internal pointer to keep track of the next row.…Displaying the first list puts the pointer at the end of the results set, so before…trying to use the results again, we need to move the pointer back to the beginning.…If you watched the first half of this course,…
Author
Released
7/7/2014- Connecting to a database with PDO or MySQLi
- Fetching a result set
- Executing simple non-SELECT queries
- Sanitizing user input
- Binding input and output values
- Passing an array of values to the execute() method
- Working with advanced PDO fetch methods
- Executing a MySQLi transaction
- Freeing resources that are no longer needed
- Submitting multiple queries
- Creating an instance of a class from a result set
Skill Level Intermediate
Duration
Views
Related Courses
-
Advanced PHP: Debugging Techniques
with Jon Peck1h 29m Intermediate
-
Introduction
-
Welcome1m
-
Using the exercise files4m 56s
-
Setting SQLite permissions1m 11s
-
-
1. Why Use Object-Oriented PHP to Access a Database?
-
Using prepared statements4m 24s
-
Using transactions1m 43s
-
2. PHP Data Object (PDO) Basics
-
Fetching a result set8m 3s
-
Getting error messages7m 17s
-
3. PDO-Prepared Statements and Transactions
-
Using named parameters9m 51s
-
Binding results to variables7m 53s
-
Executing a transaction6m 54s
-
4. Advanced PDO Fetch Methods
-
Reusing a result set7m 53s
-
5. MySQL Improved Basics
-
Setting the character set1m 57s
-
Fetching the result7m 35s
-
Handling non-SELECT queries5m 27s
-
Getting error messages5m 47s
-
6. MySQLi Prepared Statements and Transactions
-
Binding output variables5m 6s
-
7. Diving Deeper into MySQLi
-
Using real_query()6m 1s
-
Submitting multiple queries6m 41s
-
Conclusion
-
PDO and MySQLi compared3m 31s
-
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.
CancelTake notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.
Share this video
Embed this video
Video: Rewinding the result for reuse