class Schema1 { protected $type = null; protected $source = null; protected $condition = null; public function select() { $this->type = 'select'; return $this; } public function from($from) { $this->source = $from; return $this; } public function where($condition) { $this->condition = $condition; return $this; } public function result() { // Построение запроса return $query; } } class Schema2 { public $type = null; public $source = null; public $condition = null; public function execute() { if(method_exists($this, $this->type)) { $method = $this->type; return $this->$method(); } } public function select() { // Построение запроса return mysql_query($query); } } class Schema3 { public function select() { $query = self::queryBuilder('SELECT', func_get_args()); } public function create() { $query = self::queryBuilder('INSERT', func_get_args()); } public function update() { $query = self::queryBuilder('UPDATE', func_get_args()); } public function delete() { $query = self::queryBuilder('DELETE', func_get_args()); } protected static function queryBuilder($action, $from) { // Построение запроса } } class Schema4 { protected static function queryBuilder($action, $from) { // Построение запроса } public function __call($method, $args) { $query = self::queryBuilder(strtoupper($method), $args); $result = self::execute($query); if(!is_resource($result)) { return self::wrapData($result); } } }