chce przepisać swoją klasę do obsługi SQL w sposób jaki jest wykorzystywane w Zen
lecz niewiem w jaki sposób zadeklarować dane w klasie abym mógł wykonywać w ten sposób obsługę :
$users = $sql->select('COUNT(*)')->where('user = 1')->order('ASC');
class test { function __construct() { } function __set($name,$value) { $this->name = $value ; } function __get($name) { return $this->name ; } public function select($select) { return 'SELECT '.$select ; } function from($table) { return $this ; } function where($where) { return 'WHERE '.$where ; } function order($type) { } function __destruct() { } } $test = new test ;
class test { function __construct() { } function __set($name,$value) { $this->name = $value ; } function __get($name) { return $this->name ; } public function select($select) { $this->query['SELECT'] = $select ; } public function from($table) { $this->query['FROM'] = $table ; } function where($where) { $this->query['WHERE'] = $where ; } function order($type) { } function __destruct() { } } $test = new test() ; $test->select('COUNT(*)')->from('users')->where('User=2');
<?php class test { function __construct() { } function __set($name,$value) { $this->$name = $value ; } function __get($name) { return $this->$name ; } public function select($select) { $this->query['SELECT'] = $select ; return $this; } public function from($table) { $this->query['FROM'] = $table ; return $this; } function where($where) { $this->query['WHERE'] = $where ; return $this; } function order($type) { } function __destruct() { } } $test = new test() ; $test->select('COUNT(*)')->from('users')->where('User=2'); ?>