From the course: PHP: Design Patterns
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Introducing the table data gateway pattern - PHP Tutorial
From the course: PHP: Design Patterns
Introducing the table data gateway pattern
- Now let's talk about the Table Data Gateway, which is the second data access pattern we'll cover. As you've been watching these videos, you may wonder why we're covering this one after already discussing active record. After all, they're both ways to interact with the database. Do we really need both? In short, yes. Active record was built on the idea of interacting with individual database rows, embedding that logic directly into your domain logic. While that works in many scenarios, it can get messy blending those types of logic. And that's the fundamental problem. One of the concepts of good, object-oriented design is single responsibility. Which means that an object should have one, and only one purpose, and stick to that. Once you start embedding your database access into your domain logic, you can easily end up with these massive objects that are challenging to maintain. Even worse, with poorly designed objects, you can end up with the database logic spread all over the place,…
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)
Introducing the table data gateway pattern1m 58s
-
(Locked)
Exploring a use case for the table data gateway pattern1m 48s
-
(Locked)
The table data gateway pattern in action1m 4s
-
(Locked)
Challenge: Apply the table data gateway pattern29s
-
(Locked)
Solution: Apply the table data gateway pattern50s
-
(Locked)
-