- Table data gateway is common to implement…in any of the major frameworks,…so they make it incredibly easy.…We can spend our time deleting code…instead of writing new.…In this example, I've used composer…to install the zen.dv library.…It's already in the vendor directory,…so you don't have to do anything.…Let's start an index.php.…As you can see, it hasn't changed much.…Instead of using load all and load by id,…we go to a more generic select method for both method calls.…Here and here, but for the second,…we add an additional parameter to get the id that we need.…
Now let's look at our user gateway.…You'll see that beyond the constructor,…which makes the database connection,…it's empty, we don't have any other methods.…How did we get away with that?…Well, Zen's table data gateway…wires all the other logic for us.…Now, if we didn't want to change our code…in the original index.php,…we could wire the class as I have in user2.php.…This allows us to keep the original interfaces,…and preserve backwards compatibility…
Author
Released
1/28/2015- Accessing data with the active record and table data gateway patterns
- Creating objects with the factory, singleton, and mock objects patterns
- Extending code with decorator and adapter patterns
- Structuring applications with MVC and Action-Domain-Responder patterns
Each chapter features a design pattern in a real-world coding scenario, and closes with a practice challenge to test your new skills.
Skill Level Intermediate
Duration
Views
Related Courses
-
PHP: Creating Secure Websites (2014)
with Kevin Skoglund4h 15m Intermediate -
PHP: Accessing Databases with PDO and MySQLi
with David Powers3h 47m Intermediate
-
Introduction
-
Welcome51s
-
-
1. The Active Record Pattern
-
2. The Adapter Pattern
-
3. The Decorator Pattern
-
4. The Factory Pattern
-
5. Mock Objects
-
Introducing mock objects2m 18s
-
-
6. The Model-View-Controller Pattern
-
7. The Action-Domain-Response Pattern
-
8. The Publish/Subscriber Pattern
-
9. The Singleton Pattern
-
10. The Strategy Pattern
-
11. The Table Data Gateway Pattern
-
Conclusion
-
Next steps2m 8s
-
- 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: The table data gateway pattern in action