1、内核更新

2、可关闭手机站
This commit is contained in:
2017-01-04 19:51:59 +08:00
parent c7bdf42447
commit 77c1f9c8bf
86 changed files with 230 additions and 108 deletions

View File

@@ -2,7 +2,7 @@
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006~2016 http://thinkphp.cn All rights reserved.
// | Copyright (c) 2006~2017 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
@@ -797,6 +797,68 @@ class Query
return $this;
}
/**
* 设置数据
* @access public
* @param mixed $field 字段名或者数据
* @param mixed $value 字段值
* @return $this
*/
public function data($field, $value = null)
{
if (is_array($field)) {
$this->options['data'] = isset($this->options['data']) ? array_merge($this->options['data'], $field) : $field;
} else {
$this->options['data'][$field] = $value;
}
return $this;
}
/**
* 字段值增长
* @access public
* @param string|array $field 字段名
* @param integer $step 增长值
* @return $this
*/
public function inc($field, $step = 1)
{
$fields = is_string($field) ? explode(',', $field) : $field;
foreach ($fields as $field) {
$this->data($field, ['exp', $field . '+' . $step]);
}
return $this;
}
/**
* 字段值减少
* @access public
* @param string|array $field 字段名
* @param integer $step 增长值
* @return $this
*/
public function dec($field, $step = 1)
{
$fields = is_string($field) ? explode(',', $field) : $field;
foreach ($fields as $field) {
$this->data($field, ['exp', $field . '-' . $step]);
}
return $this;
}
/**
* 使用表达式设置数据
* @access public
* @param string $field 字段名
* @param string $value 字段值
* @return $this
*/
public function exp($field, $value)
{
$this->data($field, ['exp', $value]);
return $this;
}
/**
* 指定JOIN查询字段
* @access public
@@ -956,7 +1018,11 @@ class Query
// 字段相等查询
$where[$field] = ['eq', $op];
} else {
$where[$field] = [$op, $condition];
$where[$field] = [$op, $condition, isset($param[2]) ? $param[2] : null];
if ('exp' == strtolower($op) && isset($param[2]) && is_array($param[2])) {
// 参数绑定
$this->bind($param[2]);
}
// 记录一个字段多次查询条件
$this->options['multi'][$field][] = $where[$field];
}
@@ -1000,14 +1066,16 @@ class Query
}
/**
* 去除某个查询参数
* 去除查询参数
* @access public
* @param string $option 参数名
* @param string|bool $option 参数名 true 表示去除所有参数
* @return $this
*/
public function removeOption($option)
public function removeOption($option = true)
{
if (isset($this->options[$option])) {
if (true === $option) {
$this->options = [];
} elseif (is_string($option) && isset($this->options[$option])) {
unset($this->options[$option]);
}
return $this;
@@ -1796,10 +1864,11 @@ class Query
* @param string $sequence 自增序列名
* @return integer|string
*/
public function insert(array $data, $replace = false, $getLastInsID = false, $sequence = null)
public function insert(array $data = [], $replace = false, $getLastInsID = false, $sequence = null)
{
// 分析查询表达式
$options = $this->parseExpress();
$data = array_merge($options['data'], $data);
// 生成SQL语句
$sql = $this->builder->insert($data, $options, $replace);
// 获取参数绑定
@@ -1894,9 +1963,10 @@ class Query
* @throws Exception
* @throws PDOException
*/
public function update(array $data)
public function update(array $data = [])
{
$options = $this->parseExpress();
$data = array_merge($options['data'], $data);
$pk = $this->getPk($options);
if (isset($options['cache']) && is_string($options['cache'])) {
$key = $options['cache'];
@@ -2376,6 +2446,10 @@ class Query
$options['field'] = '*';
}
if (!isset($options['data'])) {
$options['data'] = [];
}
if (!isset($options['strict'])) {
$options['strict'] = $this->getConfig('fields_strict');
}