/** * Executes query without caching, completely ignored by cache * * @param string $query * @return integer */ function query_nocache($query) { $return_val = parent::query($query); return $return_val; }
/** * Executes query * * @param string $query * @return integer */ function query($query) { if (!$this->ready) { return false; } $reason = ''; $cached = false; $data = false; $time_total = 0; $this->query_total++; $caching = $this->_can_cache($query, $reason); if ($caching) { $this->timer_start(); $cache_key = $this->_get_cache_key($query); $cache =& $this->_get_cache(); $data = $cache->get($cache_key); $time_total = $this->timer_stop(); } if (is_array($data)) { $cached = true; $this->query_hits++; $this->last_error = $data['last_error']; $this->last_query = $data['last_query']; $this->last_result = $data['last_result']; $this->col_info = $data['col_info']; $this->num_rows = $data['num_rows']; $return_val = $data['return_val']; } else { $this->query_misses++; $this->timer_start(); $return_val = parent::query($query); $time_total = $this->timer_stop(); if ($caching) { $data = array('last_error' => $this->last_error, 'last_query' => $this->last_query, 'last_result' => $this->last_result, 'col_info' => $this->col_info, 'num_rows' => $this->num_rows, 'return_val' => $return_val); $cache =& $this->_get_cache(); $cache->set($cache_key, $data, $this->_lifetime); } } if ($this->_config->get_boolean('dbcache.debug')) { $this->query_stats[] = array('query' => $query, 'caching' => $caching, 'reason' => $reason, 'cached' => $cached, 'data_size' => $data ? strlen(serialize($data)) : 0, 'time_total' => $time_total); } $this->time_total += $time_total; return $return_val; }
/** * Default implementation, calls wp_db apropriate method */ function default_query($query) { return parent::query($query); }