…We have seen how to use the query method to submit select queries.…You can also use it for non-select queries but there is another…method called exact that's probably more…useful for insert, update and delete queries.…Let's take a look at both query and exact and see how they differ.…This is query_insert.php, which you can find in the…chapter 2, 02_07 folder of the exercise files.…On lines four and five is an insert statement…that adds a new entry to the names table.…
So, let's submit that using query.…And we'll restore the return value as result.…So, our database connector, db.…Then the query method, and we pass it the SQL.…And to find out what result contains we'll use var_dump and pass it result.…So, if we save that and then load the page into a browser.…The result that we get is objects PDOStatement public queryString and…then the value of the insert statement that we've just used.…
This isn't really very useful because this works only when query succeeds.…If the query fails, it returns false.…But if you do want to inspect the contents of a non-select…
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: Executing simple non-SELECT queries