private static function &_query($query, $args = NULL) { $false = FALSE; if (empty($query)) { return $false; } if (!isset($GLOBALS['sql_query_count'])) { $GLOBALS['sql_query_count'] = 0; } else { $GLOBALS['sql_query_count']++; } if (utopia::DebugMode()) { $tID = 'QRY' . $GLOBALS['sql_query_count'] . ': ' . $query; timer_start($tID, $args); } $pdo = self::connect(); $pdo->reset(); if (is_array($args)) { foreach ($args as $a) { $pdo->addByVal($a, self::getType($a)); } } try { self::$queryCount++; $stm = $pdo->call($query); $stm->setFetchMode(PDO::FETCH_ASSOC); } catch (Exception $e) { if (utopia::DebugMode()) { $timetaken = timer_end($tID); } throw $e; } if (utopia::DebugMode()) { $timetaken = timer_end($tID); } return $stm; }
static function Finish() { if (self::$finished) { return; } self::$finished = true; while (ob_get_level() > 3) { ob_end_flush(); } timer_start('Output Template'); utopia::OutputTemplate(); timer_end('Output Template'); if (isset($GLOBALS['timers']) && utopia::DebugMode()) { echo '<pre class="uDebug"><table>'; foreach ($GLOBALS['timers'] as $name => $info) { if (!is_array($info)) { continue; } $time = !array_key_exists('time_taken', $info) ? timer_end($name) : $info['time_taken']; $time = number_format($time, 2); echo '<tr><td style="vertical-align:top;border-top:1px solid black">' . $time . '</td><td style="vertical-align:top;border-top:1px solid black">' . $name . PHP_EOL . $info['info'] . '</td></tr>'; } echo '</table></pre>'; } header('X-Runtime: ' . number_format((microtime(true) - UCORE_START_TIME) * 1000) . 'ms'); die; }
public static function toggleDebug() { utopia::DebugMode(!utopia::DebugMode()); die('window.location.reload();'); }