connection = $connection; $this->type = $type; $this->sql = trim($sql); $this->time = -microtime(TRUE); if ($type === self::QUERY && preg_match('#\(?\s*(SELECT|UPDATE|INSERT|DELETE)#iA', $this->sql, $matches)) { static $types = array( 'SELECT' => self::SELECT, 'UPDATE' => self::UPDATE, 'INSERT' => self::INSERT, 'DELETE' => self::DELETE, ); $this->type = $types[strtoupper($matches[1])]; } $rc = new ReflectionClass('dibi'); $dibiDir = dirname($rc->getFileName()) . DIRECTORY_SEPARATOR; foreach (debug_backtrace(FALSE) as $row) { if (isset($row['file']) && is_file($row['file']) && strpos($row['file'], $dibiDir) !== 0) { $this->source = array($row['file'], (int) $row['line']); break; } } dibi::$elapsedTime = FALSE; } public function done($result = NULL) { $this->result = $result; try { $this->count = $result instanceof DibiResult ? count($result) : NULL; } catch (DibiException $e) { $this->count = NULL; } $this->time += microtime(TRUE); dibi::$elapsedTime = $this->time; dibi::$totalTime += $this->time; return $this; } }