Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Event {
- protected $_data_mapper;
- public function __construct( EventDataMapper $data_mapper ) {
- $this->_data_mapper = $data_mapper;
- }
- }
- class EventDataMapper {
- protected $_db;
- public function __construct( Database $db ) {
- $this->_db = $db;
- return $this;
- }
- public function find( int $id ) {
- // do the query
- $event = new Event( $this );
- // set all the properties
- return $event;
- }
- }
- $loaded_event = ( new EventDataMapper( $db ) )->find( $event_id );
Add Comment
Please, Sign In to add comment