改进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)) { if (!empty($fields)) {
foreach ($data as $key => $val) { foreach ($data as $key => $val) {
if (!in_array(strtolower($key), $fields, true)) { if (!in_array($key, $fields, true)) {
if (Config::get('db_fields_strict')) { if (Config::get('db_fields_strict')) {
throw new Exception(' fields not exists :[ ' . $key . ' ]'); throw new Exception(' fields not exists :[ ' . $key . ' ]');
} }
@@ -1259,7 +1259,7 @@ class Model
$range = is_array($rule) ? $rule : explode(',', $rule); $range = is_array($rule) ? $rule : explode(',', $rule);
$result = 'in' == $type ? in_array($value, $range) : !in_array($value, $range); $result = 'in' == $type ? in_array($value, $range) : !in_array($value, $range);
break; break;
case 'between':// 验证是否在某个范围 case 'between': // 验证是否在某个范围
case 'notbetween': // 验证是否不在某个范围 case 'notbetween': // 验证是否不在某个范围
if (is_string($rule)) { if (is_string($rule)) {
$rule = explode(',', $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' => ['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'));
$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'));
$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', '-')); $this->assertEquals(['type' => 'module', 'module' => ['index', 'index', 'hello']], Route::parseUrl('index-index-hello', '-'));
} }