private static function _execute($sql, $params) { try { if (!self::$sqlDebug) { self::$sqlDebug = BFW_Request::get('sqlDebug'); } if (self::$sqlDebug) { $startTime = BFW_Func::getMicroTime(); } self::$sth = self::$pdo[self::$db]->prepare($sql, array(PDO::ATTR_CURSOR => PDO::CURSOR_FWDONLY)); self::$sth->execute($params); if (self::$sqlDebug) { $endTime = BFW_Func::getMicroTime(); $times = $endTime - $startTime; if (preg_match('/^SELECT/i', $sql)) { $sql = self::_getSelectSqlString($sql, $params); $explain = self::_getExpain('EXPLAIN ' . $sql); BFW_App::$appGlobal['sqlDebug'][self::$db][] = array('sql' => $sql, 'explain' => $explain, 'time' => number_format($times, 10)); } } } catch (PDOException $e) { $traceArr = $e->getTrace(); $content = '[' . date('Y-m-d H:i:s') . ']' . "\n"; foreach ($traceArr as $k => $v) { $content .= '# Error in file "' . $v['file'] . '" on line "' . $v['line'] . "\"\n"; } $content .= '# ' . $e->getMessage() . "\n" . '# SQL String: ' . $sql . "\n\n"; die($content); } }