改进Request类的param方法

This commit is contained in:
thinkphp
2016-06-20 08:56:35 +08:00
parent d213339dbd
commit ff16a4521d
2 changed files with 4 additions and 6 deletions

View File

@@ -45,6 +45,7 @@ return [
'fields not exists' => '数据表字段不存在', 'fields not exists' => '数据表字段不存在',
'where express error' => '查询表达式错误', 'where express error' => '查询表达式错误',
'no data to update' => '没有任何数据需要更新', 'no data to update' => '没有任何数据需要更新',
'miss data to insert' => '缺少需要写入的数据',
'miss complex primary data' => '缺少复合主键数据', 'miss complex primary data' => '缺少复合主键数据',
'miss update condition' => '缺少更新条件', 'miss update condition' => '缺少更新条件',
'model data Not Found' => '模型数据不存在', 'model data Not Found' => '模型数据不存在',

View File

@@ -559,9 +559,10 @@ class Request
* @access public * @access public
* @param string|array $name 变量名 * @param string|array $name 变量名
* @param mixed $default 默认值 * @param mixed $default 默认值
* @param string|array $filter 过滤方法
* @return mixed * @return mixed
*/ */
public function param($name = '', $default = null) public function param($name = '', $default = null, $filter = null)
{ {
if(is_array($name)){ if(is_array($name)){
// 设置param // 设置param
@@ -587,11 +588,7 @@ class Request
// 当前请求参数和URL地址中的参数合并 // 当前请求参数和URL地址中的参数合并
$this->param = array_merge($this->get(), $vars); $this->param = array_merge($this->get(), $vars);
} }
if ($name) { return $this->input($this->param, $name, $default, $filter);
return isset($this->param[$name]) ? $this->param[$name] : $default;
} else {
return $this->param;
}
} }
/** /**