Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • $this->request and $this->data in cakephp

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 550
    Comment on it

    Hello Readers,

    Generally, we use the $this->request and $this->data in cakephp to get and post the data in application as well as in API's. So, below we describe in brief about the request.

    $this->request:

    Above, request is the default request object used in CakePHP and is available in Controllers,Views and Helpers.

    This request is accessing request parameters into several interfaces.The 1st uses object properties, 2nd uses array indexes and the 3rd uses params like:

    $this->request->controller;
    $this->request['controller'];
    $this->request->params['controller'];
    

    We also use $this->request->is(post) to post the data and has replaced the $this->request->isPost().

    Here, is('post'): Check to see whether the current request is a POST.

    We also use request as $this->request->input(json_decode) to decode the encoded data.

    It was used till cakephp 1.3, now $this->request->data has replaced $this->data array from cakephp 2.x onwards and $this->request->data is basically is used into the current version of cakephp.

    For backward compatibility $this->data is also still supported.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: