PHP Objects, Patterns and Practice (3rd edition)
CHAPTER 13 ■ DATABASE PATTERNS return $obj; } protected function doInsert( \woo\domain\DomainObject $object ) { print "inserting ...
CHAPTER 13 ■ DATABASE PATTERNS Once again, here is a client perspective on inserting and updating: $venue = new \woo\domain\Venu ...
CHAPTER 13 ■ DATABASE PATTERNS Here is an Iterator implementation that wraps an array but also accepts a Mapper object in its co ...
CHAPTER 13 ■ DATABASE PATTERNS $this->pointer = 0; } public function current() { return $this->getRow( $this->pointer ) ...
CHAPTER 13 ■ DATABASE PATTERNS The VenueCollection class simply extends Collection and implements a targetClass() method. This, ...
CHAPTER 13 ■ DATABASE PATTERNS Because the Domain Model needs to instantiate Collection objects, and because I may need to switc ...
CHAPTER 13 ■ DATABASE PATTERNS Figure 13–3. Using a factory object as an intermediary to acquire persistence tools // Venue // n ...
CHAPTER 13 ■ DATABASE PATTERNS // namespace woo\mapper; // ... protected function doCreateObject( array $array ) { $obj = new w\ ...
CHAPTER 13 ■ DATABASE PATTERNS $this->findByVenueStmt->fetchAll(), $this ); } The findByVenue() method is identical to fin ...
CHAPTER 13 ■ DATABASE PATTERNS Of course, your code may become less portable as a result of that, but efficiency optimization al ...
CHAPTER 13 ■ DATABASE PATTERNS always have that kind of control over the situation. The same object may be referenced at several ...
CHAPTER 13 ■ DATABASE PATTERNS Figure 13–5. Identity Map The main trick with an Identity Map is, pretty obviously, identifying o ...
CHAPTER 13 ■ DATABASE PATTERNS function createObject( $array ) { $old = $this->getFromMap( $array['id']); if ( $old ) { retur ...
CHAPTER 13 ■ DATABASE PATTERNS The Problem One day, I echoed my SQL statements to the browser window to track down a problem and ...
CHAPTER 13 ■ DATABASE PATTERNS $self->new = array_filter( $self->new, function( $a ) use ( $obj ) { return !( $a === $obj ...
CHAPTER 13 ■ DATABASE PATTERNS abstract class DomainObject { private $id = -1; function __construct( $id=null ) { if ( is_null( ...
CHAPTER 13 ■ DATABASE PATTERNS persistent storage. Magic is nice, but clarity is nicer. It may be better to require client code ...
CHAPTER 13 ■ DATABASE PATTERNS inserting The Green Trees inserting The Space Upstairs inserting The Bar Stage Because a high-lev ...
CHAPTER 13 ■ DATABASE PATTERNS Implementation As you may know, a Lazy Load means to defer acquisition of a property until it is ...
CHAPTER 13 ■ DATABASE PATTERNS } } As you can see, this class extends a standard EventCollection. Its constructor requires Event ...
«
11
12
13
14
15
16
17
18
19
20
»
Free download pdf