From the course: PHP: Object-Oriented Programming with Databases
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Delete a record - PHP Tutorial
From the course: PHP: Object-Oriented Programming with Databases
Delete a record
- [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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
(Locked)
CRUD operations5m 59s
-
Create a record9m 35s
-
(Locked)
Dynamic attribute list7m 59s
-
(Locked)
Sanitize values for database4m 40s
-
(Locked)
Find record to update8m 34s
-
(Locked)
Update a record11m 30s
-
(Locked)
HTML forms for OOP5m 38s
-
(Locked)
Validations and errors8m 22s
-
(Locked)
Delete a record7m 21s
-
(Locked)
Create inheritable code11m 12s
-
(Locked)
-
-
-