public function startQuery($sql, $parameters = null, $stack = array()) { if (!$this->enabled) { return null; } // try to detect the query type switch (strtolower(substr(ltrim($sql), 0, 6))) { case 'select': $queryType = static::SELECT; break; case 'insert': $queryType = static::INSERT; break; case 'update': $queryType = static::UPDATE; break; case 'delete': $queryType = static::DELETE; break; default: $queryType = static::QUERY; break; } $profile = new Query($sql, $queryType, $parameters, $stack); $this->profiles[] = $profile; $profile->start(); end($this->profiles); return key($this->profiles); }
/** * Load the next round of models. */ private function loadModels() { $start = $this->rangeStart($this->pointer, $this->limit); if ($this->loadedStart !== $start) { $this->query->start($start); $this->models = $this->query->execute(); $this->loadedStart = $start; } }