Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class MRY_DatabaseWrapper extends database {
- public $_columns = array ();
- public $_values = array ();
- public $_where = array ();
- public $_table = array ();
- public $_joinTable = array ();
- public $_type = 'select';
- public $query;
- public function column ($column) {
- $this->_columns[] = $column;
- return $this;
- }
- public function table ($table) {
- $this->_table[] = $table;
- return $this;
- }
- public function values ($values) {
- $this->_values[] = $values;
- return $this;
- }
- public function where ($column, $type, $value) {
- $this->_where[] = $column . ' ' . $type . ' ' . $value;
- return $this;
- }
- public function type ($type) {
- $this->_type = $type;
- return $this;
- }
- public function joinTable ($type, $table) {
- $this->_joinTable[] = $type . ' ' . $table;
- return $this;
- }
- public function fetch () {
- $data = $this->_query ();
- return $data;
- }
- public function _query () {
- switch ($this->_type) {
- case 'select':
- $query = 'SELECT ';
- $query .= implode (',', $this->_columns);
- $query .= ' FROM ' . current ($this->_table);
- $where = array ();
- if (!empty ($this->_where)) {
- $query .= ' WHERE ' . implode (' AND ', $this->_where);
- }
- parent::query ($query);
- $data = parent::fetch ();
- break;
- }
- var_dump ($query, $data);
- return $data;
- }
- public function _get () {
- //var_dump ($this);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement