Discover how to define a delete method that will automatically create an SQL DELETE statement to remove the associated record in the database.
- [Instructor] Now that we've talked about…how to create, read, and update…using the active record pattern,…we have one more operation to talk about.…And that is delete.…Delete is by far the simplest…of all the four major operations.…We don't have to worry about getting…any form data to submit to the database,…and we don't have to worry about…working with any data that we get back from the database.…We just simply tell the database…to delete a specific record,…and it either does or it doesn't.…It's that simple.…Let's remind ourselves…what an SQL delete statement looks like.…
It's also very simple.…We just have DELETE FROM, and then the table name,…and in this case, bicycles.…And then we have to tell it how to find…the record or records that it should delete.…Most of time we just want to delete a single record,…and we're going to use it's primary key,…which is its id.…So I have a WHERE clause, where id='1'.…I'm putting that inside single quotes…to help prevent SQL injection.…And then I'm also using a LIMIT clause…after that just to make sure that I don't…
Note: This is an intermediate-level training course that assumes you have existing knowledge of PHP. To refresh your skills, check out PHP Essential Training and PHP: Object-Oriented Programming.
- Creating a project database and tables
- Connecting to the database
- Database queries with OOP
- The active record design pattern
- Defining a database-driven class
- Performing common database tasks with OOP
- Creating inheritable and reusable code
- Object-oriented user authentication
- Object-oriented pagination
Skill Level Intermediate
Consuming RESTful APIs in PHP with Guzzlewith Justin Yost2h 12m Intermediate
PHP: Accessing Databases with PDO and MySQLiwith David Powers3h 47m Intermediate
1. Overview and Project Setup
2. The Database Connection
3. Define a Database-Driven Class
4. Object-Oriented CRUD
5. Object-Oriented Authentication
6. Object-Oriented Pagination
- 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.Cancel
Take 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.