内核更新

This commit is contained in:
2016-08-16 16:14:36 +08:00
parent ebde0fc13e
commit 81a25be484
25 changed files with 340 additions and 129 deletions
+28 -2
View File
@@ -187,11 +187,12 @@ if (!function_exists('db')) {
* 实例化数据库类
* @param string $name 操作的数据表名称(不含前缀)
* @param array|string $config 数据库配置参数
* @param bool $force 是否强制重新连接
* @return \think\db\Query
*/
function db($name = '', $config = [])
function db($name = '', $config = [], $force = true)
{
return Db::connect($config, true)->name($name);
return Db::connect($config, $force)->name($name);
}
}
@@ -510,3 +511,28 @@ if (!function_exists('abort')) {
}
}
}
if (!function_exists('halt')) {
/**
* 调试变量并且中断输出
* @param mixed $var 调试变量或者信息
*/
function halt($var)
{
dump($var);
throw new \think\exception\HttpResponseException(new Response);
}
}
if (!function_exists('token')) {
/**
* 生成表单令牌
* @param string $name 令牌名称
* @param mixed $type 令牌生成方法
*/
function token($name = '__token__', $type = 'md5')
{
$token = Request::instance()->token($name, $type);
return '<input type="hidden" name="' . $name . '" value="' . $token . '" />';
}
}