1、内核更新
2、bug修复
This commit is contained in:
@@ -45,6 +45,10 @@ class InitHook {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected function setRoute(){
|
protected function setRoute(){
|
||||||
|
$list = db('Rewrite')->select();
|
||||||
|
foreach ($list as $key => $value) {
|
||||||
|
$route[$value['rule']] = $value['url'];
|
||||||
|
}
|
||||||
$model = db('Model');
|
$model = db('Model');
|
||||||
$map = array(
|
$map = array(
|
||||||
'status' => array('gt',0),
|
'status' => array('gt',0),
|
||||||
@@ -66,11 +70,6 @@ class InitHook {
|
|||||||
$route["user/".$value['name']."/del"] = "user/content/del?model_id=".$value['id'];
|
$route["user/".$value['name']."/del"] = "user/content/del?model_id=".$value['id'];
|
||||||
$route["user/".$value['name']."/status"] = "user/content/status?model_id=".$value['id'];
|
$route["user/".$value['name']."/status"] = "user/content/status?model_id=".$value['id'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$list = db('Rewrite')->select();
|
|
||||||
foreach ($list as $key => $value) {
|
|
||||||
$route[$value['rule']] = $value['url'];
|
|
||||||
}
|
|
||||||
\think\Route::rule($route);
|
\think\Route::rule($route);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -36,15 +36,6 @@ class Content extends Base{
|
|||||||
return $value ? strtotime($value) : time();
|
return $value ? strtotime($value) : time();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected function getCreateTimeAttr($value){
|
|
||||||
return date('Y-m-d H:i:s',$value);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function getUpdateTimeAttr($value){
|
|
||||||
return date('Y-m-d H:i:s',$value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function extend($name){
|
public function extend($name){
|
||||||
$this->name = $name;
|
$this->name = $name;
|
||||||
return $this;
|
return $this;
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ class Build
|
|||||||
foreach ($list as $dir) {
|
foreach ($list as $dir) {
|
||||||
if (!is_dir(APP_PATH . $dir)) {
|
if (!is_dir(APP_PATH . $dir)) {
|
||||||
// 创建目录
|
// 创建目录
|
||||||
mkdir(APP_PATH . $dir, 0644, true);
|
mkdir(APP_PATH . $dir, 0755, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -73,7 +73,7 @@ class Build
|
|||||||
foreach ($list as $file) {
|
foreach ($list as $file) {
|
||||||
if (!is_dir(APP_PATH . dirname($file))) {
|
if (!is_dir(APP_PATH . dirname($file))) {
|
||||||
// 创建目录
|
// 创建目录
|
||||||
mkdir(APP_PATH . dirname($file), 0644, true);
|
mkdir(APP_PATH . dirname($file), 0755, true);
|
||||||
}
|
}
|
||||||
if (!is_file(APP_PATH . $file)) {
|
if (!is_file(APP_PATH . $file)) {
|
||||||
file_put_contents(APP_PATH . $file, 'php' == pathinfo($file, PATHINFO_EXTENSION) ? "<?php\n" : '');
|
file_put_contents(APP_PATH . $file, 'php' == pathinfo($file, PATHINFO_EXTENSION) ? "<?php\n" : '');
|
||||||
@@ -118,7 +118,7 @@ class Build
|
|||||||
foreach ($file as $dir) {
|
foreach ($file as $dir) {
|
||||||
if (!is_dir($modulePath . $dir)) {
|
if (!is_dir($modulePath . $dir)) {
|
||||||
// 创建目录
|
// 创建目录
|
||||||
mkdir($modulePath . $dir, 0644, true);
|
mkdir($modulePath . $dir, 0755, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} elseif ('__file__' == $path) {
|
} elseif ('__file__' == $path) {
|
||||||
@@ -146,7 +146,7 @@ class Build
|
|||||||
$filename = $modulePath . $path . DS . $val . '.html';
|
$filename = $modulePath . $path . DS . $val . '.html';
|
||||||
if (!is_dir(dirname($filename))) {
|
if (!is_dir(dirname($filename))) {
|
||||||
// 创建目录
|
// 创建目录
|
||||||
mkdir(dirname($filename), 0644, true);
|
mkdir(dirname($filename), 0755, true);
|
||||||
}
|
}
|
||||||
$content = '';
|
$content = '';
|
||||||
break;
|
break;
|
||||||
@@ -178,7 +178,7 @@ class Build
|
|||||||
$content = file_get_contents(THINK_PATH . 'tpl' . DS . 'default_index.tpl');
|
$content = file_get_contents(THINK_PATH . 'tpl' . DS . 'default_index.tpl');
|
||||||
$content = str_replace(['{$app}', '{$module}', '{layer}', '{$suffix}'], [$namespace, $module ? $module . '\\' : '', 'controller', $suffix ? 'Controller' : ''], $content);
|
$content = str_replace(['{$app}', '{$module}', '{layer}', '{$suffix}'], [$namespace, $module ? $module . '\\' : '', 'controller', $suffix ? 'Controller' : ''], $content);
|
||||||
if (!is_dir(dirname($filename))) {
|
if (!is_dir(dirname($filename))) {
|
||||||
mkdir(dirname($filename), 0644, true);
|
mkdir(dirname($filename), 0755, true);
|
||||||
}
|
}
|
||||||
file_put_contents($filename, $content);
|
file_put_contents($filename, $content);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ class File extends SplFileObject
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mkdir($path, 0644, true)) {
|
if (mkdir($path, 0755, true)) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
$this->error = "目录 {$path} 创建失败!";
|
$this->error = "目录 {$path} 创建失败!";
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ abstract class Paginator
|
|||||||
'fragment' => ''
|
'fragment' => ''
|
||||||
];
|
];
|
||||||
|
|
||||||
public function __construct($items, $listRows, $currentPage = null, $simple = false, $total = null, $options = [])
|
protected function __construct($items, $listRows, $currentPage = null, $total = null, $simple = false, $options = [])
|
||||||
{
|
{
|
||||||
$this->options = array_merge($this->options, $options);
|
$this->options = array_merge($this->options, $options);
|
||||||
|
|
||||||
@@ -71,12 +71,21 @@ abstract class Paginator
|
|||||||
$this->items = PaginatorCollection::make($items, $this);
|
$this->items = PaginatorCollection::make($items, $this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function items()
|
/**
|
||||||
|
* @param $items
|
||||||
|
* @param $listRows
|
||||||
|
* @param null $currentPage
|
||||||
|
* @param bool $simple
|
||||||
|
* @param null $total
|
||||||
|
* @param array $options
|
||||||
|
* @return PaginatorCollection
|
||||||
|
*/
|
||||||
|
public static function make($items, $listRows, $currentPage = null, $total = null, $simple = false, $options = [])
|
||||||
{
|
{
|
||||||
return $this->items;
|
$paginator = new static($items, $listRows, $currentPage, $total, $simple, $options);
|
||||||
|
return $paginator->items;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected function setCurrentPage($currentPage)
|
protected function setCurrentPage($currentPage)
|
||||||
{
|
{
|
||||||
if (!$this->simple && $currentPage > $this->lastPage) {
|
if (!$this->simple && $currentPage > $this->lastPage) {
|
||||||
|
|||||||
@@ -443,7 +443,9 @@ class Route
|
|||||||
|| (isset($option['except']) && in_array($key, $option['except']))) {
|
|| (isset($option['except']) && in_array($key, $option['except']))) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (strpos($val[1], ':id') && isset($option['var'][$rule])) {
|
if (isset($last) && strpos($val[1], ':id') && isset($option['var'][$last])) {
|
||||||
|
$val[1] = str_replace(':id', ':' . $option['var'][$last], $val[1]);
|
||||||
|
} elseif (strpos($val[1], ':id') && isset($option['var'][$rule])) {
|
||||||
$val[1] = str_replace(':id', ':' . $option['var'][$rule], $val[1]);
|
$val[1] = str_replace(':id', ':' . $option['var'][$rule], $val[1]);
|
||||||
}
|
}
|
||||||
$item = ltrim($rule . $val[1], '/');
|
$item = ltrim($rule . $val[1], '/');
|
||||||
|
|||||||
@@ -19,6 +19,9 @@ use think\Route;
|
|||||||
|
|
||||||
class Url
|
class Url
|
||||||
{
|
{
|
||||||
|
// 生成URL地址的root
|
||||||
|
protected static $root;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* URL生成 支持路由反射
|
* URL生成 支持路由反射
|
||||||
* @param string $url URL表达式,
|
* @param string $url URL表达式,
|
||||||
@@ -113,7 +116,7 @@ class Url
|
|||||||
// 检测域名
|
// 检测域名
|
||||||
$domain = self::parseDomain($url, $domain);
|
$domain = self::parseDomain($url, $domain);
|
||||||
// URL组装
|
// URL组装
|
||||||
$url = $domain . Request::instance()->root() . '/' . ltrim($url, '/');
|
$url = $domain . (self::$root ?: Request::instance()->root()) . '/' . ltrim($url, '/');
|
||||||
return $url;
|
return $url;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -316,4 +319,11 @@ class Url
|
|||||||
{
|
{
|
||||||
Cache::rm('think_route_map');
|
Cache::rm('think_route_map');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 指定当前生成URL地址的root
|
||||||
|
public static function root($root)
|
||||||
|
{
|
||||||
|
self::$root = $root;
|
||||||
|
Request::instance()->root($root);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -28,7 +28,7 @@ abstract class Builder
|
|||||||
protected $options = [];
|
protected $options = [];
|
||||||
|
|
||||||
// 数据库表达式
|
// 数据库表达式
|
||||||
protected $exp = ['eq' => '=', 'neq' => '<>', 'gt' => '>', 'egt' => '>=', 'lt' => '<', 'elt' => '<=', 'notlike' => 'NOT LIKE', 'like' => 'LIKE', 'in' => 'IN', 'exp' => 'EXP', 'notin' => 'NOT IN', 'not in' => 'NOT IN', 'between' => 'BETWEEN', 'not between' => 'NOT BETWEEN', 'notbetween' => 'NOT BETWEEN', 'exists' => 'EXISTS', 'notexists' => 'NOT EXISTS', 'not exists' => 'NOT EXISTS', 'null' => 'NULL', 'notnull' => 'NOT NULL', 'not null' => 'NOT NULL', '> time' => '> TIME', '< time' => '< TIME', 'between time' => 'BETWEEN TIME', 'not between time' => 'NOT BETWEEN TIME', 'notbetween time' => 'NOT BETWEEN TIME'];
|
protected $exp = ['eq' => '=', 'neq' => '<>', 'gt' => '>', 'egt' => '>=', 'lt' => '<', 'elt' => '<=', 'notlike' => 'NOT LIKE', 'like' => 'LIKE', 'in' => 'IN', 'exp' => 'EXP', 'notin' => 'NOT IN', 'not in' => 'NOT IN', 'between' => 'BETWEEN', 'not between' => 'NOT BETWEEN', 'notbetween' => 'NOT BETWEEN', 'exists' => 'EXISTS', 'notexists' => 'NOT EXISTS', 'not exists' => 'NOT EXISTS', 'null' => 'NULL', 'notnull' => 'NOT NULL', 'not null' => 'NOT NULL', '> time' => '> TIME', '< time' => '< TIME', '>= time' => '>= TIME', '<= time' => '<= TIME', 'between time' => 'BETWEEN TIME', 'not between time' => 'NOT BETWEEN TIME', 'notbetween time' => 'NOT BETWEEN TIME'];
|
||||||
|
|
||||||
// SQL表达式
|
// SQL表达式
|
||||||
protected $selectSql = 'SELECT%DISTINCT% %FIELD% FROM %TABLE%%FORCE%%JOIN%%WHERE%%GROUP%%HAVING%%ORDER%%LIMIT% %UNION%%LOCK%%COMMENT%';
|
protected $selectSql = 'SELECT%DISTINCT% %FIELD% FROM %TABLE%%FORCE%%JOIN%%WHERE%%GROUP%%HAVING%%ORDER%%LIMIT% %UNION%%LOCK%%COMMENT%';
|
||||||
@@ -199,12 +199,13 @@ abstract class Builder
|
|||||||
/**
|
/**
|
||||||
* where分析
|
* where分析
|
||||||
* @access protected
|
* @access protected
|
||||||
* @param mixed $where
|
* @param mixed $where 查询条件
|
||||||
|
* @param array $options 查询参数
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function parseWhere($where, $table)
|
protected function parseWhere($where, $options)
|
||||||
{
|
{
|
||||||
$whereStr = $this->buildWhere($where, $table);
|
$whereStr = $this->buildWhere($where, $options);
|
||||||
return empty($whereStr) ? '' : ' WHERE ' . $whereStr;
|
return empty($whereStr) ? '' : ' WHERE ' . $whereStr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -212,23 +213,23 @@ abstract class Builder
|
|||||||
* 生成查询条件SQL
|
* 生成查询条件SQL
|
||||||
* @access public
|
* @access public
|
||||||
* @param mixed $where
|
* @param mixed $where
|
||||||
* @param string $table
|
* @param array $options
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function buildWhere($where, $table)
|
public function buildWhere($where, $options)
|
||||||
{
|
{
|
||||||
if (empty($where)) {
|
if (empty($where)) {
|
||||||
$where = [];
|
$where = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($where instanceof Query) {
|
if ($where instanceof Query) {
|
||||||
return $this->buildWhere($where->getOptions('where'), $table);
|
return $this->buildWhere($where->getOptions('where'), $options);
|
||||||
}
|
}
|
||||||
|
|
||||||
$whereStr = '';
|
$whereStr = '';
|
||||||
// 获取字段信息
|
// 获取字段信息
|
||||||
$fields = $this->query->getTableInfo($table, 'fields');
|
$fields = $this->query->getTableInfo($options['table'], 'fields');
|
||||||
$binds = $this->query->getTableInfo($table, 'bind');
|
$binds = $this->query->getTableInfo($options['table'], 'bind');
|
||||||
foreach ($where as $key => $val) {
|
foreach ($where as $key => $val) {
|
||||||
$str = [];
|
$str = [];
|
||||||
foreach ($val as $field => $value) {
|
foreach ($val as $field => $value) {
|
||||||
@@ -240,14 +241,14 @@ abstract class Builder
|
|||||||
// 使用闭包查询
|
// 使用闭包查询
|
||||||
$query = new Query($this->connection);
|
$query = new Query($this->connection);
|
||||||
call_user_func_array($value, [ & $query]);
|
call_user_func_array($value, [ & $query]);
|
||||||
$str[] = ' ' . $key . ' ( ' . $this->buildWhere($query->getOptions('where'), $table) . ' )';
|
$str[] = ' ' . $key . ' ( ' . $this->buildWhere($query->getOptions('where'), $options) . ' )';
|
||||||
} else {
|
} else {
|
||||||
if (strpos($field, '|')) {
|
if (strpos($field, '|')) {
|
||||||
// 不同字段使用相同查询条件(OR)
|
// 不同字段使用相同查询条件(OR)
|
||||||
$array = explode('|', $field);
|
$array = explode('|', $field);
|
||||||
$item = [];
|
$item = [];
|
||||||
foreach ($array as $k) {
|
foreach ($array as $k) {
|
||||||
$item[] = $this->parseWhereItem($k, $value);
|
$item[] = $this->parseWhereItem($k, $value, '', $options);
|
||||||
}
|
}
|
||||||
$str[] = ' ' . $key . ' ( ' . implode(' OR ', $item) . ' )';
|
$str[] = ' ' . $key . ' ( ' . implode(' OR ', $item) . ' )';
|
||||||
} elseif (strpos($field, '&')) {
|
} elseif (strpos($field, '&')) {
|
||||||
@@ -255,13 +256,13 @@ abstract class Builder
|
|||||||
$array = explode('&', $field);
|
$array = explode('&', $field);
|
||||||
$item = [];
|
$item = [];
|
||||||
foreach ($array as $k) {
|
foreach ($array as $k) {
|
||||||
$item[] = $this->parseWhereItem($k, $value);
|
$item[] = $this->parseWhereItem($k, $value, '', $options);
|
||||||
}
|
}
|
||||||
$str[] = ' ' . $key . ' ( ' . implode(' AND ', $item) . ' )';
|
$str[] = ' ' . $key . ' ( ' . implode(' AND ', $item) . ' )';
|
||||||
} else {
|
} else {
|
||||||
// 对字段使用表达式查询
|
// 对字段使用表达式查询
|
||||||
$field = is_string($field) ? $field : '';
|
$field = is_string($field) ? $field : '';
|
||||||
$str[] = ' ' . $key . ' ' . $this->parseWhereItem($field, $value, $key);
|
$str[] = ' ' . $key . ' ' . $this->parseWhereItem($field, $value, $key, $options);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -272,7 +273,7 @@ abstract class Builder
|
|||||||
}
|
}
|
||||||
|
|
||||||
// where子单元分析
|
// where子单元分析
|
||||||
protected function parseWhereItem($field, $val, $rule = '')
|
protected function parseWhereItem($field, $val, $rule = '', $options = [])
|
||||||
{
|
{
|
||||||
// 字段分析
|
// 字段分析
|
||||||
$key = $field ? $this->parseKey($field) : '';
|
$key = $field ? $this->parseKey($field) : '';
|
||||||
@@ -293,7 +294,7 @@ abstract class Builder
|
|||||||
array_push($val, $item);
|
array_push($val, $item);
|
||||||
}
|
}
|
||||||
foreach ($val as $item) {
|
foreach ($val as $item) {
|
||||||
$str[] = $this->parseWhereItem($key, $item, $rule);
|
$str[] = $this->parseWhereItem($key, $item, $rule, $options);
|
||||||
}
|
}
|
||||||
return '( ' . implode(' ' . $rule . ' ', $str) . ' )';
|
return '( ' . implode(' ' . $rule . ' ', $str) . ' )';
|
||||||
}
|
}
|
||||||
@@ -338,13 +339,13 @@ abstract class Builder
|
|||||||
} else {
|
} else {
|
||||||
$whereStr .= $exp . ' (' . $value . ')';
|
$whereStr .= $exp . ' (' . $value . ')';
|
||||||
}
|
}
|
||||||
} elseif (in_array($exp, ['< TIME', '> TIME'])) {
|
} elseif (in_array($exp, ['< TIME', '> TIME', '<= TIME', '>= TIME'])) {
|
||||||
$whereStr .= $key . ' ' . substr($exp, 0, 1) . ' ' . $this->parseDateTime($value, $field);
|
$whereStr .= $key . ' ' . substr($exp, 0, 2) . ' ' . $this->parseDateTime($value, $field, $options);
|
||||||
} elseif (in_array($exp, ['BETWEEN TIME', 'NOT BETWEEN TIME'])) {
|
} elseif (in_array($exp, ['BETWEEN TIME', 'NOT BETWEEN TIME'])) {
|
||||||
if (is_string($value)) {
|
if (is_string($value)) {
|
||||||
$value = explode(',', $value);
|
$value = explode(',', $value);
|
||||||
}
|
}
|
||||||
$whereStr .= $key . ' ' . substr($exp, 0, -4) . $this->parseDateTime($value[0], $field) . ' AND ' . $this->parseDateTime($value[1], $field);
|
$whereStr .= $key . ' ' . substr($exp, 0, -4) . $this->parseDateTime($value[0], $field, $options) . ' AND ' . $this->parseDateTime($value[1], $field, $options);
|
||||||
}
|
}
|
||||||
return $whereStr;
|
return $whereStr;
|
||||||
}
|
}
|
||||||
@@ -362,18 +363,24 @@ abstract class Builder
|
|||||||
* @access protected
|
* @access protected
|
||||||
* @param string $value
|
* @param string $value
|
||||||
* @param string $key
|
* @param string $key
|
||||||
|
* @param array $options
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function parseDateTime($value, $key)
|
protected function parseDateTime($value, $key, $options = [])
|
||||||
{
|
{
|
||||||
// 获取时间字段类型
|
// 获取时间字段类型
|
||||||
$type = $this->query->getTableInfo('', 'type');
|
$type = $this->query->getTableInfo('', 'type');
|
||||||
if (isset($type[$key])) {
|
if (isset($options['field_type'][$key])) {
|
||||||
|
$info = $options['field_type'][$key];
|
||||||
|
} elseif (isset($type[$key])) {
|
||||||
|
$info = $type[$key];
|
||||||
|
}
|
||||||
|
if (isset($info)) {
|
||||||
$value = strtotime($value) ?: $value;
|
$value = strtotime($value) ?: $value;
|
||||||
if (preg_match('/(datetime|timestamp)/is', $type[$key])) {
|
if (preg_match('/(datetime|timestamp)/is', $info)) {
|
||||||
// 日期及时间戳类型
|
// 日期及时间戳类型
|
||||||
$value = date('Y-m-d H:i:s', $value);
|
$value = date('Y-m-d H:i:s', $value);
|
||||||
} elseif (preg_match('/(date)/is', $type[$key])) {
|
} elseif (preg_match('/(date)/is', $info)) {
|
||||||
// 日期及时间戳类型
|
// 日期及时间戳类型
|
||||||
$value = date('Y-m-d', $value);
|
$value = date('Y-m-d', $value);
|
||||||
}
|
}
|
||||||
@@ -546,7 +553,7 @@ abstract class Builder
|
|||||||
$this->parseDistinct($options['distinct']),
|
$this->parseDistinct($options['distinct']),
|
||||||
$this->parseField($options['field']),
|
$this->parseField($options['field']),
|
||||||
$this->parseJoin($options['join']),
|
$this->parseJoin($options['join']),
|
||||||
$this->parseWhere($options['where'], $options['table']),
|
$this->parseWhere($options['where'], $options),
|
||||||
$this->parseGroup($options['group']),
|
$this->parseGroup($options['group']),
|
||||||
$this->parseHaving($options['having']),
|
$this->parseHaving($options['having']),
|
||||||
$this->parseOrder($options['order']),
|
$this->parseOrder($options['order']),
|
||||||
@@ -679,7 +686,7 @@ abstract class Builder
|
|||||||
$this->parseTable($options['table']),
|
$this->parseTable($options['table']),
|
||||||
implode(',', $set),
|
implode(',', $set),
|
||||||
$this->parseJoin($options['join']),
|
$this->parseJoin($options['join']),
|
||||||
$this->parseWhere($options['where'], $options['table']),
|
$this->parseWhere($options['where'], $options),
|
||||||
$this->parseOrder($options['order']),
|
$this->parseOrder($options['order']),
|
||||||
$this->parseLimit($options['limit']),
|
$this->parseLimit($options['limit']),
|
||||||
$this->parseLimit($options['lock']),
|
$this->parseLimit($options['lock']),
|
||||||
@@ -703,7 +710,7 @@ abstract class Builder
|
|||||||
$this->parseTable($options['table']),
|
$this->parseTable($options['table']),
|
||||||
!empty($options['using']) ? ' USING ' . $this->parseTable($options['using']) . ' ' : '',
|
!empty($options['using']) ? ' USING ' . $this->parseTable($options['using']) . ' ' : '',
|
||||||
$this->parseJoin($options['join']),
|
$this->parseJoin($options['join']),
|
||||||
$this->parseWhere($options['where'], $options['table']),
|
$this->parseWhere($options['where'], $options),
|
||||||
$this->parseOrder($options['order']),
|
$this->parseOrder($options['order']),
|
||||||
$this->parseLimit($options['limit']),
|
$this->parseLimit($options['limit']),
|
||||||
$this->parseLimit($options['lock']),
|
$this->parseLimit($options['lock']),
|
||||||
|
|||||||
@@ -972,6 +972,8 @@ class Query
|
|||||||
{
|
{
|
||||||
$config = array_merge(Config::get('paginate'), $config);
|
$config = array_merge(Config::get('paginate'), $config);
|
||||||
$listRows = $listRows ?: $config['list_rows'];
|
$listRows = $listRows ?: $config['list_rows'];
|
||||||
|
|
||||||
|
/** @var Paginator $class */
|
||||||
$class = false !== strpos($config['type'], '\\') ? $config['type'] : '\\think\\paginator\\driver\\' . ucwords($config['type']);
|
$class = false !== strpos($config['type'], '\\') ? $config['type'] : '\\think\\paginator\\driver\\' . ucwords($config['type']);
|
||||||
$page = isset($config['page']) ? (int)$config['page'] : call_user_func([
|
$page = isset($config['page']) ? (int)$config['page'] : call_user_func([
|
||||||
$class,
|
$class,
|
||||||
@@ -982,7 +984,6 @@ class Query
|
|||||||
|
|
||||||
$config['path'] = isset($config['path']) ? $config['path'] : call_user_func([$class, 'getCurrentPath']);
|
$config['path'] = isset($config['path']) ? $config['path'] : call_user_func([$class, 'getCurrentPath']);
|
||||||
|
|
||||||
/** @var Paginator $paginator */
|
|
||||||
if (!$simple) {
|
if (!$simple) {
|
||||||
$options = $this->getOptions();
|
$options = $this->getOptions();
|
||||||
$total = $this->count();
|
$total = $this->count();
|
||||||
@@ -992,8 +993,7 @@ class Query
|
|||||||
$total = null;
|
$total = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$paginator = new $class($results, $listRows, $page, $simple, $total, $config);
|
return $class::make($results, $listRows, $page, $total, $simple, $config);
|
||||||
return $paginator->items();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1287,6 +1287,18 @@ class Query
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置字段类型
|
||||||
|
* @access public
|
||||||
|
* @param array $fieldType 字段类型信息
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setFieldType($fieldType = [])
|
||||||
|
{
|
||||||
|
$this->options['field_type'] = $fieldType;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取数据表信息
|
* 获取数据表信息
|
||||||
* @access public
|
* @access public
|
||||||
|
|||||||
@@ -224,7 +224,7 @@ class Merge extends Model
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 处理模型数据
|
// 处理模型数据
|
||||||
$data = $this->parseData($this->name, $this->data);
|
$data = $this->parseData($this->name, $this->data, true);
|
||||||
// 写入主表数据
|
// 写入主表数据
|
||||||
$result = $db->name($this->name)->strict(false)->insert($data, $replace);
|
$result = $db->name($this->name)->strict(false)->insert($data, $replace);
|
||||||
if ($result) {
|
if ($result) {
|
||||||
|
|||||||
@@ -23,6 +23,8 @@ use think\Paginator;
|
|||||||
* @method string render()
|
* @method string render()
|
||||||
* @method Paginator fragment($fragment)
|
* @method Paginator fragment($fragment)
|
||||||
* @method Paginator appends($key, $value)
|
* @method Paginator appends($key, $value)
|
||||||
|
* @method integer lastPage()
|
||||||
|
* @method boolean hasPages()
|
||||||
*/
|
*/
|
||||||
class Collection extends \think\Collection
|
class Collection extends \think\Collection
|
||||||
{
|
{
|
||||||
@@ -41,16 +43,6 @@ class Collection extends \think\Collection
|
|||||||
return new static($items, $paginator);
|
return new static($items, $paginator);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setPaginator(Paginator $paginator)
|
|
||||||
{
|
|
||||||
$this->paginator = $paginator;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getPaginator()
|
|
||||||
{
|
|
||||||
return $this->paginator;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function toArray()
|
public function toArray()
|
||||||
{
|
{
|
||||||
if ($this->paginator) {
|
if ($this->paginator) {
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ class File
|
|||||||
// 检测模板目录
|
// 检测模板目录
|
||||||
$dir = dirname($cacheFile);
|
$dir = dirname($cacheFile);
|
||||||
if (!is_dir($dir)) {
|
if (!is_dir($dir)) {
|
||||||
mkdir($dir, 0644, true);
|
mkdir($dir, 0755, true);
|
||||||
}
|
}
|
||||||
// 生成模板缓存文件
|
// 生成模板缓存文件
|
||||||
if (false === file_put_contents($cacheFile, $content)) {
|
if (false === file_put_contents($cacheFile, $content)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user