改进Model类一处大小写字段的识别错误

This commit is contained in:
thinkphp
2016-03-01 20:37:35 +08:00
parent 8e05713b6a
commit 28a627acac
2 changed files with 6 additions and 4 deletions

View File

@@ -260,7 +260,7 @@ class Model
// 检查非数据字段
if (!empty($fields)) {
foreach ($data as $key => $val) {
if (!in_array(strtolower($key), $fields, true)) {
if (!in_array($key, $fields, true)) {
if (Config::get('db_fields_strict')) {
throw new Exception(' fields not exists :[ ' . $key . ' ]');
}
@@ -1248,7 +1248,7 @@ class Model
// 行为验证
$result = Hook::exec($rule, '', $data);
break;
case 'filter': // 使用filter_var验证
case 'filter': // 使用filter_var验证
$result = filter_var($value, is_int($rule) ? $rule : filter_id($rule), $options);
break;
case 'confirm':
@@ -1259,8 +1259,8 @@ class Model
$range = is_array($rule) ? $rule : explode(',', $rule);
$result = 'in' == $type ? in_array($value, $range) : !in_array($value, $range);
break;
case 'between':// 验证是否在某个范围
case 'notbetween': // 验证是否不在某个范围
case 'between': // 验证是否在某个范围
case 'notbetween': // 验证是否不在某个范围
if (is_string($rule)) {
$rule = explode(',', $rule);
}

View File

@@ -73,7 +73,9 @@ class routeTest extends \PHPUnit_Framework_TestCase
{
$this->assertEquals(['type' => 'module', 'module' => ['hello', null, null]], Route::parseUrl('hello'));
$this->assertEquals(['type' => 'module', 'module' => ['index', 'hello', null]], Route::parseUrl('index/hello'));
$this->assertEquals(['type' => 'module', 'module' => ['index', 'hello', null]], Route::parseUrl('index/hello?name=thinkphp'));
$this->assertEquals(['type' => 'module', 'module' => ['index', 'user', 'hello']], Route::parseUrl('index/user/hello'));
$this->assertEquals(['type' => 'module', 'module' => ['index', 'user', 'hello']], Route::parseUrl('index/user/hello/name/thinkphp'));
$this->assertEquals(['type' => 'module', 'module' => ['index', 'index', 'hello']], Route::parseUrl('index-index-hello', '-'));
}