caching("table"); * * @return string */ public function caching($table) { return ($this->_config['caching'] AND isset($this->_config['cache'][$table])) ? $this->_config['cache'][$table] : FALSE; } private function clear() { $this->_query_msg_codes = array(); } public function query($type, $sql, $as_object = FALSE, array $params = NULL) { // Make sure the database is connected $this->_connection or $this->connect(); $this->clear(); if ( ! empty($this->_config['profiling'])) // Benchmark this query for the current instance $benchmark = Profiler::start("Database ({$this->_instance})", $sql); // Execute the query $result = $this->execute($sql); if ($this->execute_stderr AND $this->execute_rc) { // This benchmark is worthless if (isset($benchmark)) Profiler::delete($benchmark); SystemMessage::TSM_Error(sprintf('%s (%s)',$this->execute_stdout,$this->execute_stderr),$sql); Request::current()->redirect('welcome'); } if (isset($benchmark)) Profiler::stop($benchmark); // Set the last query $this->last_query = $sql; if ($type === Database::SELECT) // Return an iterator of results return new Database_TSM_Result($result, $sql, $as_object, $params); elseif ($type === Database::INSERT) throw new Kohana_Exception('Database INSERTS are not supported'); elseif ($type === Database::SHOW) return new Database_TSM_Show($result, $sql, $as_object, $params); elseif ($type === Database::SET) return new Database_TSM_Set($result, $sql, $as_object, $params); } public function escape($value) { // Make sure the database is connected $this->_connection or $this->connect(); // SQL standard is to use single-quotes for all values return "'$value'"; } } ?>