JBHUTT09

Untitled

Aug 23rd, 2017
22
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.67 KB | None | 0 0
  1.  
  2.    
  3.     class Event {
  4.         protected $_data_mapper;
  5.        
  6.         public function __construct( EventDataMapper $data_mapper ) {
  7.             $this->_data_mapper = $data_mapper;
  8.         }
  9.     }
  10.    
  11.     class EventDataMapper {
  12.         protected $_db;
  13.        
  14.         public function __construct( Database $db ) {
  15.             $this->_db = $db;
  16.             return $this;
  17.         }
  18.        
  19.         public function find( int $id ) {
  20.             // do the query
  21.             $event = new Event( $this );
  22.             // set all the properties
  23.             return $event;
  24.         }
  25.     }
  26.    
  27.     $loaded_event = ( new EventDataMapper( $db ) )->find( $event_id );
Add Comment
Please, Sign In to add comment