Cakephp Classroom image

osdyui
 
To post your Question Join Classroom
 
Lesson Topics's No:-  First|10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18|Last
Lessons:-Controllers

Accessing Querystring parameters
Querystring parameters can be read from using CakeRequest::$query:
// url is /posts/index?page=1&sort=title
$this->request->query[’page’];
// You can also access it via array access
$this->request[’url’][’page’]; // BC accessor, will be deprecated in future versionsYou can either directly access the query property, or you can use CakeRequest::query() to read the
url query array in an error free manner. Any keys that do not exist will return null:
$foo = $this->request->query(’value_that_does_not_exist’);
// $foo === null
Accessing POST data
All POST data can be accessed using CakeRequest::$data. Any form data that contains a data
prefix, will have that data prefix removed. For example:
// An input with a name attribute equal to ’data[MyModel][title]’ is accessible at
$this->request->data[’MyModel’][’title’];
You can either directly access the data property, or you can use CakeRequest::data() to read the data
array in an error free manner. Any keys that do not exist will return null:
$foo = $this->request->data(’Value.that.does.not.exist’);
// $foo == null
Accessing PUT or POST data
New in version 2.2. When building REST services you often accept request data on PUT and DELETE requests.
As of 2.2 any application/x-www-form-urlencoded request body data will automatically
be parsed and set to $this->data for PUT and DELETE requests. If you are accepting JSON or XML
data, see below for how you can access those request bodies.
Accessing XML or JSON data
Applications employing REST often exchange data in non URL encoded post bodies. You can read input
data in any format using CakeRequest::input(). By providing a decoding function you can receive
the content in a deserialized format:
// Get JSON encoded data submitted to a PUT/POST action
$data = $this->request->input(’json_decode’);
Since some deserializing methods require additional parameters when being called, such as the ‘as
array’ parameter on json_decode or if you want XML converted into a DOMDocument object,
CakeRequest::input() supports passing in additional parameters as well:
// Get Xml encoded data submitted to a PUT/POST action
$data = $this->request->input(’Xml::build’, array(’return’ => ’domdocument’));

 
 
 

osdyui

Skills    Cakephp

Qualifications :-
Location :-,,,
Description:-
Explore
 

  Students (0)