/** * 返回字段值 * 示例: $db_obj->single('select name from `test` where `id`=:id', array('id'=>7)) * 结果: ryan * @param string $query * @param array $params */ public function single($query, $params = null) { $this->_init($query, $params); $res = $this->_sQuery->fetchColumn(); $log = array('sql' => $query, 'params' => is_array($params) ? json_encode($params) : $params, 'data' => is_array($res) ? json_encode($res) : $res); C::log($log); return $res; }
private static function _halt($e) { if (DEBUG) { if (IS_CLI) { exit(iconv('UTF-8', 'gbk', $e->getMessage()) . PHP_EOL . 'FILE: ' . $e->getFile() . '(' . $e->getLine() . ')' . PHP_EOL . $e->getTraceAsString() . PHP_EOL); } include_once ONEFOX_PATH . DS . 'tpl' . DS . 'excetion.html'; } else { $log_info['url'] = $_SERVER['REQUEST_URI']; $log_info['errmsg'] = $e->getMessage(); $log_info['file'] = $e->getFile(); $log_info['line'] = $e->getLine(); C::log($log_info, Log::ERROR); //记录错误日志 if (IS_CLI) { exit; } $url = Config::get('404_page'); if ($url) { Response::redirect($url); } header('HTTP/1.1 404 Not Found'); header('Status:404 Not Found'); include_once ONEFOX_PATH . DS . 'tpl' . DS . '404.html'; } }