codepad
[
create a new paste
]
login
|
about
Language:
C
C++
D
Haskell
Lua
OCaml
PHP
Perl
Plain Text
Python
Ruby
Scheme
Tcl
<?php // Entity class Book { private $id; private $title; public function __construct($id, $title) { $this->id = $id; $this->title = $title; } ... getters and setters methods ... } // DAO (Data access object) class BookDao { public function findBookByName($name) { $db = Database::getInstance(); $row = $db->select('book')->where('name = ?', $name); return new Book($row['id'], ['title']); } } // Registry class Registry { private static $objects = array(); public static function get($index){} public static function set($index, $value){} public static function isRegistered($index){} } $dao = new BookDao(); Registry::set('BookDao', $dao); ... $dao = Registry::get('BookDao'); $book1 = $dao->findBookByName('Example 1'); $book2 = $dao->findBookByName('Example 2');
Private
[
?
]
Run code