| | |
| | | |
| | | // Query database (read operations) |
| | | |
| | | function query($query) |
| | | function query($query, $offset=0, $numrows=0) |
| | | { |
| | | // Read or write ? |
| | | if (strtolower(trim(substr($query,0,6)))=='select') |
| | |
| | | |
| | | if ($this->db_provider == 'sqlite') |
| | | $query = $this->_sqlite_prepare_query($query); |
| | | |
| | | $result = $this->db_handle->query($query); |
| | | |
| | | if ($numrows || $offset) |
| | | { |
| | | $result = $this->db_handle->limitQuery($query,$offset,$numrows); |
| | | } |
| | | else |
| | | $result = $this->db_handle->query($query); |
| | | |
| | | if (DB::isError($result)) |
| | | raise_error(array('code' => 500, |
| | |
| | | 'message' => $result->getMessage()), TRUE, FALSE); |
| | | |
| | | return $this->_add_result($result, $query); |
| | | } |
| | | |
| | | function db_execute ($query) |
| | | { |
| | | $this->db_connect('w'); |
| | | |
| | | if ($this->db_provider == 'sqlite') |
| | | $query = $this->_sqlite_prepare_query($query); |
| | | |
| | | $result = $this->db_handle->query($query); |
| | | |
| | | } |
| | | |
| | | function num_rows($res_id=NULL) |