Skip to content

Commit

Permalink
Fixed issue #197.
Browse files Browse the repository at this point in the history
  • Loading branch information
qiang.xue committed Mar 30, 2009
1 parent 8c0f78a commit f445b05
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ Version 1.0.4 to be released
- New #171: Added version info to yiic help output (Qiang)
- New #172: Added eAccelerator cache driver (Steffen)
- New #195: Added CModel::scenario property (Qiang)
- New #197: Added getParam, getQueryParam and getPostParam to CHttpRequest (Qiang)
- New #203: Added CZendDataCache (Steffen)
- New #207: Enhanced CHtml::activeFileField so that we can still use $_POST to detect form submission under some rare cases (Qiang)
- New #212: 'Readline' support in yiic console script (olafure)
Expand Down
46 changes: 46 additions & 0 deletions framework/web/CHttpRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,52 @@ public function stripSlashes(&$data)
return is_array($data)?array_map(array($this,'stripSlashes'),$data):stripslashes($data);
}

/**
* Returns the named GET or POST parameter value.
* If the GET or POST parameter does not exist, the second parameter to this method will be returned.
* If both GET and POST contains such a named parameter, the GET parameter takes precedence.
* @param string the GET parameter name
* @param mixed the default parameter value if the GET parameter does not exist.
* @return mixed the GET parameter value
* @since 1.0.4
* @see getQuery
* @see getPost
*/
public function getParam($name,$defaultValue=null)
{
return isset($_GET[$name]) ? $_GET[$name] : (isset($_POST[$name]) ? $_POST[$name] : $defaultValue);
}

/**
* Returns the named GET parameter value.
* If the GET parameter does not exist, the second parameter to this method will be returned.
* @param string the GET parameter name
* @param mixed the default parameter value if the GET parameter does not exist.
* @return mixed the GET parameter value
* @since 1.0.4
* @see getPost
* @see getParam
*/
public function getQuery($name,$defaultValue=null)
{
return isset($_GET[$name]) ? $_GET[$name] : $defaultValue;
}

/**
* Returns the named POST parameter value.
* If the POST parameter does not exist, the second parameter to this method will be returned.
* @param string the POST parameter name
* @param mixed the default parameter value if the POST parameter does not exist.
* @return mixed the POST parameter value
* @since 1.0.4
* @see getParam
* @see getQuery
*/
public function getPost($name,$defaultValue=null)
{
return isset($_POST[$name]) ? $_POST[$name] : $defaultValue;
}

/**
* @return string part of the request URL after the host info.
* It consists of the following parts:
Expand Down

0 comments on commit f445b05

Please sign in to comment.