/** * Register functions * * @param Twig_Environment $twig twig environment * @return Twig_Environment twig environment */ private static function registerFunctions($twig) { $function = new Twig_SimpleFunction('request_time', function () { return round(microtime(true) - START_REQUEST, 2); }); $twig->addFunction($function); $function = new Twig_SimpleFunction('database_queries', function () { return QueryCounter::get(); }); $twig->addFunction($function); return $twig; }
/** * Generate the PDO statement * * @return \PDOStatement statement */ public function prepare() { $q = $this->buildQueryString(); $stmt = $this->pdo->prepare($q); foreach ($this->boundParameters as $i => $value) { $stmt->bindValue(":" . $i, $value); } QueryCounter::increment(); return $stmt; }