diff --git a/application/chengji/controller/Index.php b/application/chengji/controller/Index.php
index 5a277bb2..33494232 100644
--- a/application/chengji/controller/Index.php
+++ b/application/chengji/controller/Index.php
@@ -230,6 +230,47 @@ class Index extends Base
}
+
+
+ // 删除成绩
+ public function delete($id)
+ {
+
+ if($id == 'm')
+ {
+ $id = request()->delete('ids/a');// 获取delete请求方式传送过来的数据并转换成数据
+ }
+
+ $data = Chengji::destroy($id);
+
+ // 根据更新结果设置返回提示信息
+ $data ? $data=['msg'=>'删除成功','val'=>1] : $data=['msg'=>'数据处理错误','val'=>0];
+
+ // 返回信息
+ return json($data);
+ }
+
+
+
+ // 设置成绩状态
+ public function setStatus()
+ {
+
+ // 获取id变量
+ $id = request()->post('id');
+ $value = request()->post('value');
+
+ // 获取班级信息
+ $data = Chengji::where('id',$id)->update(['status'=>$value]);
+
+ // 根据更新结果设置返回提示信息
+ $data ? $data=['msg'=>'状态设置成功','val'=>1] : $data=['msg'=>'数据处理错误','val'=>0];
+
+ // 返回信息
+ return json($data);
+ }
+
+
diff --git a/application/chengji/view/index/chengjilist.html b/application/chengji/view/index/chengjilist.html
index d848fbe5..dca066a7 100644
--- a/application/chengji/view/index/chengjilist.html
+++ b/application/chengji/view/index/chengjilist.html
@@ -108,11 +108,9 @@
// 启用按钮
startbut = '';
// 编辑按钮
- editbut = '';
+ editbut = '';
// 删除按钮
- delbut = '';
- // 生成考号
- morebut = '';
+ delbut = '';
if(row.status == '已停用')
{
@@ -120,7 +118,7 @@
}else{
buts = stopbut;
}
- buts = buts + editbut + delbut + morebut;
+ buts = buts + editbut + delbut;
return buts;
}
diff --git a/composer.lock b/composer.lock
index f8551122..31952c88 100644
--- a/composer.lock
+++ b/composer.lock
@@ -1054,16 +1054,16 @@
},
{
"name": "topthink/framework",
- "version": "v5.1.28",
+ "version": "v5.1.29",
"source": {
"type": "git",
"url": "https://github.com/top-think/framework.git",
- "reference": "b5077520855a1f406205687c73cdeaee1ed618c2"
+ "reference": "f1d8ee3a91e8f504507edb5dcc49c50c47b4500f"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/top-think/framework/zipball/b5077520855a1f406205687c73cdeaee1ed618c2",
- "reference": "b5077520855a1f406205687c73cdeaee1ed618c2",
+ "url": "https://api.github.com/repos/top-think/framework/zipball/f1d8ee3a91e8f504507edb5dcc49c50c47b4500f",
+ "reference": "f1d8ee3a91e8f504507edb5dcc49c50c47b4500f",
"shasum": "",
"mirrors": [
{
@@ -1107,7 +1107,7 @@
"orm",
"thinkphp"
],
- "time": "2018-10-29T02:52:45+00:00"
+ "time": "2018-11-11T01:17:33+00:00"
},
{
"name": "topthink/think-captcha",
diff --git a/route/chengji.php b/route/chengji.php
index cde5c774..39016298 100644
--- a/route/chengji.php
+++ b/route/chengji.php
@@ -10,6 +10,7 @@
// +----------------------------------------------------------------------
//系统设置路由
+Route::resource('chengji','Chengji/Index');
Route::get('chengji/malu','chengji/Index/malu');
Route::post('chengji/malu','chengji/Index/malusave');
Route::post('chengji/read','chengji/Index/read');
diff --git a/thinkphp/README.md b/thinkphp/README.md
index a30e8f0e..b2a791b8 100644
--- a/thinkphp/README.md
+++ b/thinkphp/README.md
@@ -1,4 +1,4 @@
-
+
ThinkPHP 5.1(LTS) —— 12载初心,你值得信赖的PHP框架
===============
diff --git a/thinkphp/library/think/App.php b/thinkphp/library/think/App.php
index 254f53a9..c9522fa9 100644
--- a/thinkphp/library/think/App.php
+++ b/thinkphp/library/think/App.php
@@ -20,7 +20,7 @@ use think\route\Dispatch;
*/
class App extends Container
{
- const VERSION = '5.1.28 LTS';
+ const VERSION = '5.1.29 LTS';
/**
* 当前模块路径
diff --git a/thinkphp/library/think/Config.php b/thinkphp/library/think/Config.php
index 5cf0df16..bec6222a 100644
--- a/thinkphp/library/think/Config.php
+++ b/thinkphp/library/think/Config.php
@@ -187,7 +187,7 @@ class Config implements \ArrayAccess
*/
public function has($name)
{
- if (!strpos($name, '.')) {
+ if (false === strpos($name, '.')) {
$name = $this->prefix . '.' . $name;
}
@@ -225,7 +225,7 @@ class Config implements \ArrayAccess
*/
public function get($name = null, $default = null)
{
- if ($name && !strpos($name, '.')) {
+ if ($name && false === strpos($name, '.')) {
$name = $this->prefix . '.' . $name;
}
@@ -272,7 +272,7 @@ class Config implements \ArrayAccess
public function set($name, $value = null)
{
if (is_string($name)) {
- if (!strpos($name, '.')) {
+ if (false === strpos($name, '.')) {
$name = $this->prefix . '.' . $name;
}
@@ -314,7 +314,7 @@ class Config implements \ArrayAccess
*/
public function remove($name)
{
- if (!strpos($name, '.')) {
+ if (false === strpos($name, '.')) {
$name = $this->prefix . '.' . $name;
}
diff --git a/thinkphp/library/think/Env.php b/thinkphp/library/think/Env.php
index ef5d9468..eaeee943 100644
--- a/thinkphp/library/think/Env.php
+++ b/thinkphp/library/think/Env.php
@@ -43,7 +43,7 @@ class Env
* @param mixed $default 默认值
* @return mixed
*/
- public function get($name = null, $default = null)
+ public function get($name = null, $default = null, $php_prefix = true)
{
if (is_null($name)) {
return $this->data;
@@ -55,12 +55,16 @@ class Env
return $this->data[$name];
}
- return $this->getEnv($name, $default);
+ return $this->getEnv($name, $default, $php_prefix);
}
- protected function getEnv($name, $default = null)
+ protected function getEnv($name, $default = null, $php_prefix = true)
{
- $result = getenv('PHP_' . $name);
+ if ($php_prefix) {
+ $name = 'PHP_' . $name;
+ }
+
+ $result = getenv($name);
if (false === $result) {
return $default;
diff --git a/thinkphp/library/think/File.php b/thinkphp/library/think/File.php
index e9985690..b2906097 100644
--- a/thinkphp/library/think/File.php
+++ b/thinkphp/library/think/File.php
@@ -334,9 +334,10 @@ class File extends SplFileObject
* @param string $path 保存路径
* @param string|bool $savename 保存的文件名 默认自动生成
* @param boolean $replace 同名文件是否覆盖
+ * @param bool $autoAppendExt 自动补充扩展名
* @return false|File false-失败 否则返回File实例
*/
- public function move($path, $savename = true, $replace = true)
+ public function move($path, $savename = true, $replace = true, $autoAppendExt = true)
{
// 文件上传失败,捕获错误代码
if (!empty($this->info['error'])) {
@@ -357,7 +358,7 @@ class File extends SplFileObject
$path = rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
// 文件保存命名规则
- $saveName = $this->buildSaveName($savename);
+ $saveName = $this->buildSaveName($savename, $autoAppendExt);
$filename = $path . $saveName;
// 检测目录
@@ -391,9 +392,10 @@ class File extends SplFileObject
* 获取保存文件名
* @access protected
* @param string|bool $savename 保存的文件名 默认自动生成
+ * @param bool $autoAppendExt 自动补充扩展名
* @return string
*/
- protected function buildSaveName($savename)
+ protected function buildSaveName($savename, $autoAppendExt = true)
{
if (true === $savename) {
// 自动生成文件名
@@ -403,7 +405,7 @@ class File extends SplFileObject
$savename = $this->getInfo('name');
}
- if (!strpos($savename, '.')) {
+ if ($autoAppendExt && false === strpos($savename, '.')) {
$savename .= '.' . pathinfo($this->getInfo('name'), PATHINFO_EXTENSION);
}
diff --git a/thinkphp/library/think/Hook.php b/thinkphp/library/think/Hook.php
index b7e83deb..1d011410 100644
--- a/thinkphp/library/think/Hook.php
+++ b/thinkphp/library/think/Hook.php
@@ -192,7 +192,7 @@ class Hook
if ($class instanceof \Closure) {
$call = $class;
$class = 'Closure';
- } elseif (strpos($class, '::')) {
+ } elseif (is_array($class) || strpos($class, '::')) {
$call = $class;
} else {
$obj = Container::get($class);
diff --git a/thinkphp/library/think/Model.php b/thinkphp/library/think/Model.php
index 93914f0d..e0dcecf6 100644
--- a/thinkphp/library/think/Model.php
+++ b/thinkphp/library/think/Model.php
@@ -299,9 +299,9 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
call_user_func_array([$this, 'base'], [ & $query]);
}
- $globalScope = is_array($useBaseQuery) && $useBaseQuery ?: $this->globalScope;
+ $globalScope = is_array($useBaseQuery) && $useBaseQuery ? $useBaseQuery : $this->globalScope;
- if ($globalScope) {
+ if ($globalScope && false !== $useBaseQuery) {
$query->scope($globalScope);
}
diff --git a/thinkphp/library/think/Route.php b/thinkphp/library/think/Route.php
index ed66c51d..5122aec9 100644
--- a/thinkphp/library/think/Route.php
+++ b/thinkphp/library/think/Route.php
@@ -326,7 +326,7 @@ class Route
// 支持多个域名使用相同路由规则
$domainName = is_array($name) ? array_shift($name) : $name;
- if ('*' != $domainName && !strpos($domainName, '.')) {
+ if ('*' != $domainName && false === strpos($domainName, '.')) {
$domainName .= '.' . $this->request->rootDomain();
}
@@ -344,7 +344,7 @@ class Route
if (is_array($name) && !empty($name)) {
$root = $this->request->rootDomain();
foreach ($name as $item) {
- if (!strpos($item, '.')) {
+ if (false === strpos($item, '.')) {
$item .= '.' . $root;
}
@@ -394,7 +394,7 @@ class Route
$domain = $this->domain;
} elseif (true === $domain) {
return $this->bind;
- } elseif (!strpos($domain, '.')) {
+ } elseif (false === strpos($domain, '.')) {
$domain .= '.' . $this->request->rootDomain();
}
diff --git a/thinkphp/library/think/Template.php b/thinkphp/library/think/Template.php
index a6238a65..dc1acfa5 100644
--- a/thinkphp/library/think/Template.php
+++ b/thinkphp/library/think/Template.php
@@ -387,7 +387,7 @@ class Template
}
// 优化生成的php代码
- $content = preg_replace('/\?>\s*<\?php\s(?!echo\b)/s', '', $content);
+ $content = preg_replace('/\?>\s*<\?php\s(?!echo\b|\bend)/s', '', $content);
// 模板过滤输出
$replace = $this->config['tpl_replace_string'];
@@ -1269,9 +1269,9 @@ class Template
switch ($tagName) {
case 'block':
if ($single) {
- $regex = $begin . '(?:' . $tagName . '\b(?>(?:(?!name=).)*)\bname=([\'\"])(?P[\$\w\-\/\.]+)\\1(?>[^' . $end . ']*)|\/' . $tagName . ')' . $end;
+ $regex = $begin . '(?:' . $tagName . '\b\s+(?>(?:(?!name=).)*)\bname=([\'\"])(?P[\$\w\-\/\.]+)\\1(?>[^' . $end . ']*)|\/' . $tagName . ')' . $end;
} else {
- $regex = $begin . '(?:' . $tagName . '\b(?>(?:(?!name=).)*)\bname=([\'\"])(?P[\$\w\-\/\.]+)\\1(?>(?:(?!' . $end . ').)*)|\/' . $tagName . ')' . $end;
+ $regex = $begin . '(?:' . $tagName . '\b\s+(?>(?:(?!name=).)*)\bname=([\'\"])(?P[\$\w\-\/\.]+)\\1(?>(?:(?!' . $end . ').)*)|\/' . $tagName . ')' . $end;
}
break;
case 'literal':
@@ -1297,9 +1297,9 @@ class Template
$name = 'name';
}
if ($single) {
- $regex = $begin . $tagName . '\b(?>(?:(?!' . $name . '=).)*)\b' . $name . '=([\'\"])(?P[\$\w\-\/\.\:@,\\\\]+)\\1(?>[^' . $end . ']*)' . $end;
+ $regex = $begin . $tagName . '\b\s+(?>(?:(?!' . $name . '=).)*)\b' . $name . '=([\'\"])(?P[\$\w\-\/\.\:@,\\\\]+)\\1(?>[^' . $end . ']*)' . $end;
} else {
- $regex = $begin . $tagName . '\b(?>(?:(?!' . $name . '=).)*)\b' . $name . '=([\'\"])(?P[\$\w\-\/\.\:@,\\\\]+)\\1(?>(?:(?!' . $end . ').)*)' . $end;
+ $regex = $begin . $tagName . '\b\s+(?>(?:(?!' . $name . '=).)*)\b' . $name . '=([\'\"])(?P[\$\w\-\/\.\:@,\\\\]+)\\1(?>(?:(?!' . $end . ').)*)' . $end;
}
break;
}
diff --git a/thinkphp/library/think/Url.php b/thinkphp/library/think/Url.php
index 9e41b881..2724b3f6 100644
--- a/thinkphp/library/think/Url.php
+++ b/thinkphp/library/think/Url.php
@@ -316,7 +316,7 @@ class Url
}
}
}
- } elseif (!strpos($domain, '.')) {
+ } elseif (0 !== strpos($domain, $rootDomain) && false === strpos($domain, '.')) {
$domain .= '.' . $rootDomain;
}
diff --git a/thinkphp/library/think/Validate.php b/thinkphp/library/think/Validate.php
index ebc07293..205ec072 100644
--- a/thinkphp/library/think/Validate.php
+++ b/thinkphp/library/think/Validate.php
@@ -331,10 +331,10 @@ class Validate
* 移除某个字段的验证规则
* @access public
* @param string|array $field 字段名
- * @param mixed $rule 验证规则 true 移除所有规则
+ * @param mixed $rule 验证规则 null 移除所有规则
* @return $this
*/
- public function remove($field, $rule = true)
+ public function remove($field, $rule = null)
{
if (is_array($field)) {
foreach ($field as $key => $rule) {
@@ -419,7 +419,7 @@ class Validate
continue;
}
- // 获取数据 支持二维数组
+ // 获取数据 支持多维数组
$value = $this->getDataValue($data, $key);
// 字段验证
@@ -548,7 +548,7 @@ class Validate
if (!empty($msg[$i])) {
$message = $msg[$i];
if (is_string($message) && strpos($message, '{%') === 0) {
- $message = Lang::get(substr($message, 2, -1));
+ $message = facade\Lang::get(substr($message, 2, -1));
}
} else {
$message = $this->getRuleMsg($field, $title, $info, $rule);
@@ -1404,7 +1404,7 @@ class Validate
* 获取数据值
* @access protected
* @param array $data 数据
- * @param string $key 数据标识 支持二维
+ * @param string $key 数据标识 支持多维
* @return mixed
*/
protected function getDataValue($data, $key)
@@ -1412,9 +1412,14 @@ class Validate
if (is_numeric($key)) {
$value = $key;
} elseif (strpos($key, '.')) {
- // 支持二维数组验证
- list($name1, $name2) = explode('.', $key);
- $value = isset($data[$name1][$name2]) ? $data[$name1][$name2] : null;
+ // 支持多维数组验证
+ foreach (explode('.', $key) as $key) {
+ if (!isset($data[$key])) {
+ $value = null;
+ break;
+ }
+ $value = $data = $data[$key];
+ }
} else {
$value = isset($data[$key]) ? $data[$key] : null;
}
diff --git a/thinkphp/library/think/console/command/optimize/Schema.php b/thinkphp/library/think/console/command/optimize/Schema.php
index 7b9e02d6..16ac83d5 100644
--- a/thinkphp/library/think/console/command/optimize/Schema.php
+++ b/thinkphp/library/think/console/command/optimize/Schema.php
@@ -53,7 +53,7 @@ class Schema extends Command
return;
} elseif ($input->hasOption('table')) {
$table = $input->getOption('table');
- if (!strpos($table, '.')) {
+ if (false === strpos($table, '.')) {
$dbName = Db::getConfig('database');
}
diff --git a/thinkphp/library/think/console/output/question/Choice.php b/thinkphp/library/think/console/output/question/Choice.php
index f6760e5e..cdc3b4e4 100644
--- a/thinkphp/library/think/console/output/question/Choice.php
+++ b/thinkphp/library/think/console/output/question/Choice.php
@@ -147,7 +147,7 @@ class Choice extends Question
$result = $value;
}
- if (empty($result)) {
+ if (false === $result) {
throw new \InvalidArgumentException(sprintf($errorMessage, $value));
}
array_push($multiselectChoices, $result);
diff --git a/thinkphp/library/think/db/Builder.php b/thinkphp/library/think/db/Builder.php
index daa7eda5..05d52d1b 100644
--- a/thinkphp/library/think/db/Builder.php
+++ b/thinkphp/library/think/db/Builder.php
@@ -174,9 +174,9 @@ abstract class Builder
return $data->getValue();
}
- $query->bind($data, isset($bind[$key]) ? $bind[$key] : PDO::PARAM_STR);
+ $name = $query->bind($data, isset($bind[$key]) ? $bind[$key] : PDO::PARAM_STR);
- return '?';
+ return ':' . $name;
}
/**
@@ -411,8 +411,8 @@ abstract class Builder
}
if (is_scalar($value) && !in_array($exp, ['EXP', 'NOT NULL', 'NULL', 'IN', 'NOT IN', 'BETWEEN', 'NOT BETWEEN']) && strpos($exp, 'TIME') === false) {
- $query->bind($value, $bindType);
- $value = '?';
+ $name = $query->bind($value, $bindType);
+ $value = ':' . $name;
}
// 解析查询表达式
@@ -447,12 +447,10 @@ abstract class Builder
// 模糊匹配
if (is_array($value)) {
foreach ($value as $item) {
- $bind[] = [$item, $bindType];
- $array[] = $key . ' ' . $exp . ' ?';
+ $name = $query->bind($item, $bindType);
+ $array[] = $key . ' ' . $exp . ' :' . $name;
}
- $query->bind($bind);
-
$whereStr = '(' . implode($array, ' ' . strtoupper($logic) . ' ') . ')';
} else {
$whereStr = $key . ' ' . $exp . ' ' . $value;
@@ -534,12 +532,10 @@ abstract class Builder
// BETWEEN 查询
$data = is_array($value) ? $value : explode(',', $value);
- $bind[] = [$data[0], $bindType];
- $bind[] = [$data[1], $bindType];
+ $min = $query->bind($data[0], $bindType);
+ $max = $query->bind($data[1], $bindType);
- $query->bind($bind);
-
- return $key . ' ' . $exp . ' ? AND ? ';
+ return $key . ' ' . $exp . ' :' . $min . ' AND :' . $max . ' ';
}
/**
@@ -651,16 +647,14 @@ abstract class Builder
} else {
$value = array_unique(is_array($value) ? $value : explode(',', $value));
- $bind = [];
$array = [];
foreach ($value as $k => $v) {
- $bind[] = [$v, $bindType];
- $array[] = '?';
+ $name = $query->bind($v, $bindType);
+ $array[] = ':' . $name;
}
$zone = implode(',', $array);
- $query->bind($bind);
$value = empty($zone) ? "''" : $zone;
}
@@ -728,9 +722,9 @@ abstract class Builder
}
}
- $query->bind($value, $bindType);
+ $name = $query->bind($value, $bindType);
- return '?';
+ return ':' . $name;
}
/**
diff --git a/thinkphp/library/think/db/Connection.php b/thinkphp/library/think/db/Connection.php
index 6c337bc2..914007af 100644
--- a/thinkphp/library/think/db/Connection.php
+++ b/thinkphp/library/think/db/Connection.php
@@ -361,7 +361,7 @@ abstract class Connection
list($tableName) = explode(' ', $tableName);
- if (!strpos($tableName, '.')) {
+ if (false === strpos($tableName, '.')) {
$schema = $this->getConfig('database') . '.' . $tableName;
} else {
$schema = $tableName;
@@ -1472,10 +1472,7 @@ abstract class Connection
// 判断占位符
$sql = is_numeric($key) ?
substr_replace($sql, $value, strpos($sql, '?'), 1) :
- str_replace(
- [':' . $key . ')', ':' . $key . ',', ':' . $key . ' ', ':' . $key . PHP_EOL],
- [$value . ')', $value . ',', $value . ' ', $value . PHP_EOL],
- $sql . ' ');
+ substr_replace($sql, $value, strpos($sql, ':' . $key), strlen(':' . $key));
}
return rtrim($sql);
@@ -1494,7 +1491,7 @@ abstract class Connection
{
foreach ($bind as $key => $val) {
// 占位符
- $param = is_numeric($key) ? $key + 1 : ':' . $key;
+ $param = is_int($key) ? $key + 1 : ':' . $key;
if (is_array($val)) {
if (PDO::PARAM_INT == $val[1] && '' === $val[0]) {
@@ -1530,7 +1527,7 @@ abstract class Connection
protected function bindParam($bind)
{
foreach ($bind as $key => $val) {
- $param = is_numeric($key) ? $key + 1 : ':' . $key;
+ $param = is_int($key) ? $key + 1 : ':' . $key;
if (is_array($val)) {
array_unshift($val, $param);
diff --git a/thinkphp/library/think/db/Query.php b/thinkphp/library/think/db/Query.php
index d48b95c6..9d653447 100644
--- a/thinkphp/library/think/db/Query.php
+++ b/thinkphp/library/think/db/Query.php
@@ -1417,23 +1417,18 @@ class Query
* 指定Exp查询条件
* @access public
* @param mixed $field 查询字段
- * @param string $condition 查询条件
+ * @param string $where 查询条件
* @param array $bind 参数绑定
* @param string $logic 查询逻辑 and or xor
* @return $this
*/
- public function whereExp($field, $condition, $bind = [], $logic = 'AND')
+ public function whereExp($field, $where, $bind = [], $logic = 'AND')
{
if ($bind) {
- foreach ($bind as $key => $value) {
- if (!is_numeric($key)) {
- $where = str_replace(':' . $key, '?', $where);
- }
- }
- $this->bind(array_values($bind));
+ $this->bindParams($where, $bind);
}
- $this->options['where'][$logic][] = [$field, 'EXP', $this->raw($condition)];
+ $this->options['where'][$logic][] = [$field, 'EXP', $this->raw($where)];
return $this;
}
@@ -1449,13 +1444,7 @@ class Query
public function whereRaw($where, $bind = [], $logic = 'AND')
{
if ($bind) {
- foreach ($bind as $key => $value) {
- if (!is_numeric($key)) {
- $where = str_replace(':' . $key, '?', $where);
- }
- }
-
- $this->bind(array_values($bind));
+ $this->bindParams($where, $bind);
}
$this->options['where'][$logic][] = $this->raw($where);
@@ -1463,6 +1452,30 @@ class Query
return $this;
}
+ /**
+ * 参数绑定
+ * @access public
+ * @param string $sql 绑定的sql表达式
+ * @param array $bind 参数绑定
+ * @return void
+ */
+ protected function bindParams(&$sql, array $bind = [])
+ {
+ foreach ($bind as $key => $value) {
+ if (is_array($value)) {
+ $name = $this->bind($value[0], $value[1], isset($value[2]) ? $value[2] : null);
+ } else {
+ $name = $this->bind($value);
+ }
+
+ if (is_numeric($key)) {
+ $sql = substr_replace($sql, ':' . $name, strpos($sql, '?'), 1);
+ } else {
+ $sql = str_replace(':' . $key, ':' . $name, $sql);
+ }
+ }
+ }
+
/**
* 指定表达式查询条件 OR
* @access public
@@ -1500,7 +1513,7 @@ class Query
return $this;
}
- if (is_string($field) && !empty($this->options['via']) && !strpos($field, '.')) {
+ if (is_string($field) && !empty($this->options['via']) && false === strpos($field, '.')) {
$field = $this->options['via'] . '.' . $field;
}
@@ -1893,13 +1906,7 @@ class Query
public function orderRaw($field, $bind = [])
{
if ($bind) {
- foreach ($bind as $key => $value) {
- if (!is_numeric($key)) {
- $field = str_replace(':' . $key, '?', $field);
- }
- }
-
- $this->bind(array_values($bind));
+ $this->bindParams($field, $bind);
}
$this->options['order'][] = $this->raw($field);
@@ -2444,14 +2451,18 @@ class Query
* @access public
* @param mixed $value 绑定变量值
* @param integer $type 绑定类型
- * @return $this
+ * @param string $name 绑定名称
+ * @return $this|string
*/
- public function bind($value = false, $type = PDO::PARAM_STR)
+ public function bind($value, $type = PDO::PARAM_STR, $name = null)
{
if (is_array($value)) {
$this->bind = array_merge($this->bind, $value);
} else {
- $this->bind[] = [$value, $type];
+ $name = $name ?: 'ThinkBind_' . (count($this->bind) + 1) . '_';
+
+ $this->bind[$name] = [$value, $type];
+ return $name;
}
return $this;
@@ -3648,7 +3659,7 @@ class Query
$options['field'] = '*';
}
- foreach (['data', 'order'] as $name) {
+ foreach (['data', 'order', 'join', 'union'] as $name) {
if (!isset($options[$name])) {
$options[$name] = [];
}
@@ -3668,7 +3679,7 @@ class Query
$options['master'] = true;
}
- foreach (['join', 'union', 'group', 'having', 'limit', 'force', 'comment'] as $name) {
+ foreach (['group', 'having', 'limit', 'force', 'comment'] as $name) {
if (!isset($options[$name])) {
$options[$name] = '';
}
diff --git a/thinkphp/library/think/facade/View.php b/thinkphp/library/think/facade/View.php
index 19b5f370..08433917 100644
--- a/thinkphp/library/think/facade/View.php
+++ b/thinkphp/library/think/facade/View.php
@@ -23,8 +23,8 @@ use think\Facade;
* @method \think\View exists(mixed $name) static 检查模板是否存在
* @method \think\View filter(Callable $filter) static 视图内容过滤
* @method \think\View engine(mixed $engine = []) static 设置当前模板解析的引擎
- * @method string fetch(string $template = '', array $vars = [], array $replace = [], array $config = [], bool $renderContent = false) static 解析和获取模板内容
- * @method string display(string $content = '', array $vars = [], array $replace = [], array $config = []) static 渲染内容输出
+ * @method string fetch(string $template = '', array $vars = [], array $config = [], bool $renderContent = false) static 解析和获取模板内容
+ * @method string display(string $content = '', array $vars = [], array $config = []) static 渲染内容输出
*/
class View extends Facade
{
diff --git a/thinkphp/library/think/model/concern/ModelEvent.php b/thinkphp/library/think/model/concern/ModelEvent.php
index 2bb6d5fe..3a874846 100644
--- a/thinkphp/library/think/model/concern/ModelEvent.php
+++ b/thinkphp/library/think/model/concern/ModelEvent.php
@@ -80,6 +80,8 @@ trait ModelEvent
*/
public static function observe($class)
{
+ self::flushEvent();
+
foreach (static::$observe as $event) {
$eventFuncName = Loader::parseName($event, 1, false);
diff --git a/thinkphp/library/think/model/concern/SoftDelete.php b/thinkphp/library/think/model/concern/SoftDelete.php
index 8902b388..ca55204e 100644
--- a/thinkphp/library/think/model/concern/SoftDelete.php
+++ b/thinkphp/library/think/model/concern/SoftDelete.php
@@ -212,7 +212,7 @@ trait SoftDelete
return false;
}
- if (!strpos($field, '.')) {
+ if (false === strpos($field, '.')) {
$field = '__TABLE__.' . $field;
}
diff --git a/thinkphp/library/think/model/relation/BelongsTo.php b/thinkphp/library/think/model/relation/BelongsTo.php
index a90c5418..98d176e8 100644
--- a/thinkphp/library/think/model/relation/BelongsTo.php
+++ b/thinkphp/library/think/model/relation/BelongsTo.php
@@ -135,7 +135,19 @@ class BelongsTo extends OneToOne
*/
public function has($operator = '>=', $count = 1, $id = '*', $joinType = 'INNER')
{
- return $this->parent;
+ $table = $this->query->getTable();
+ $model = basename(str_replace('\\', '/', get_class($this->parent)));
+ $relation = basename(str_replace('\\', '/', $this->model));
+ $localKey = $this->localKey;
+ $foreignKey = $this->foreignKey;
+
+ return $this->parent->db()
+ ->alias($model)
+ ->whereExists(function ($query) use ($table, $model, $relation, $localKey, $foreignKey) {
+ $query->table([$table => $relation])
+ ->field($relation . '.' . $localKey)
+ ->whereExp($model . '.' . $foreignKey, '=' . $relation . '.' . $localKey);
+ });
}
/**
diff --git a/thinkphp/library/think/model/relation/HasMany.php b/thinkphp/library/think/model/relation/HasMany.php
index 874f97b7..f679e95b 100644
--- a/thinkphp/library/think/model/relation/HasMany.php
+++ b/thinkphp/library/think/model/relation/HasMany.php
@@ -195,7 +195,7 @@ class HasMany extends Relation
}
return $this->query
- ->whereExp($this->foreignKey, '=' . $this->parent->getTable() . '.' . $this->parent->getPk())
+ ->whereExp($this->foreignKey, '=' . $this->parent->getTable() . '.' . $this->localKey)
->fetchSql()
->$aggregate($field);
}
diff --git a/thinkphp/library/think/model/relation/HasOne.php b/thinkphp/library/think/model/relation/HasOne.php
index e6620fff..d8e3ec79 100644
--- a/thinkphp/library/think/model/relation/HasOne.php
+++ b/thinkphp/library/think/model/relation/HasOne.php
@@ -88,7 +88,7 @@ class HasOne extends OneToOne
}
return $this->query
- ->whereExp($this->foreignKey, '=' . $this->parent->getTable() . '.' . $this->parent->getPk())
+ ->whereExp($this->foreignKey, '=' . $this->parent->getTable() . '.' . $this->localKey)
->fetchSql()
->$aggregate($field);
}
diff --git a/thinkphp/library/think/response/Download.php b/thinkphp/library/think/response/Download.php
index 18112926..02a440df 100644
--- a/thinkphp/library/think/response/Download.php
+++ b/thinkphp/library/think/response/Download.php
@@ -128,7 +128,7 @@ class Download extends Response
{
$this->name = $filename;
- if ($extension && !strpos($filename, '.')) {
+ if ($extension && false === strpos($filename, '.')) {
$this->name .= '.' . pathinfo($this->data, PATHINFO_EXTENSION);
}
diff --git a/thinkphp/library/think/route/Rule.php b/thinkphp/library/think/route/Rule.php
index 46c36a3c..35730fee 100644
--- a/thinkphp/library/think/route/Rule.php
+++ b/thinkphp/library/think/route/Rule.php
@@ -681,10 +681,10 @@ abstract class Rule
/**
* 合并分组参数
- * @access protected
+ * @access public
* @return array
*/
- protected function mergeGroupOptions()
+ public function mergeGroupOptions()
{
if (!$this->lockOption) {
$parentOption = $this->parent->getOption();
diff --git a/thinkphp/library/think/route/RuleGroup.php b/thinkphp/library/think/route/RuleGroup.php
index 3ebb4099..36be2f44 100644
--- a/thinkphp/library/think/route/RuleGroup.php
+++ b/thinkphp/library/think/route/RuleGroup.php
@@ -189,7 +189,7 @@ class RuleGroup extends Rule
$result = new UrlDispatch($request, $this, $this->auto . '/' . $url, ['auto_search' => false]);
} elseif ($this->miss && in_array($this->miss->getMethod(), ['*', $method])) {
// 未匹配所有路由的路由规则处理
- $result = $this->miss->parseRule($request, '', $this->miss->getRoute(), $url, $this->miss->getOption());
+ $result = $this->miss->parseRule($request, '', $this->miss->getRoute(), $url, $this->miss->mergeGroupOptions());
} else {
$result = false;
}
diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json
index dcd8887a..c36d1802 100644
--- a/vendor/composer/installed.json
+++ b/vendor/composer/installed.json
@@ -1079,17 +1079,17 @@
},
{
"name": "topthink/framework",
- "version": "v5.1.28",
- "version_normalized": "5.1.28.0",
+ "version": "v5.1.29",
+ "version_normalized": "5.1.29.0",
"source": {
"type": "git",
"url": "https://github.com/top-think/framework.git",
- "reference": "b5077520855a1f406205687c73cdeaee1ed618c2"
+ "reference": "f1d8ee3a91e8f504507edb5dcc49c50c47b4500f"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/top-think/framework/zipball/b5077520855a1f406205687c73cdeaee1ed618c2",
- "reference": "b5077520855a1f406205687c73cdeaee1ed618c2",
+ "url": "https://api.github.com/repos/top-think/framework/zipball/f1d8ee3a91e8f504507edb5dcc49c50c47b4500f",
+ "reference": "f1d8ee3a91e8f504507edb5dcc49c50c47b4500f",
"shasum": "",
"mirrors": [
{
@@ -1111,7 +1111,7 @@
"sebastian/phpcpd": "2.*",
"squizlabs/php_codesniffer": "2.*"
},
- "time": "2018-10-29T02:52:45+00:00",
+ "time": "2018-11-11T01:17:33+00:00",
"type": "think-framework",
"installation-source": "dist",
"notification-url": "https://packagist.org/downloads/",