In cakePHP 1.3 , when I try to get the variables GET sent on the url, I can use this :
$this->params['url'];
Example: url = www.mySite.com/messages/get/?var1=1&var2=2
the result of $this->params['url']; is :
Array => ( [url] => Array
(
[url] => messages/get
[var1] => 1
[var2] => 2
)
)
But when I try to get those params from the same URL using cakePHP2.0, the result is in json format:
{"params":{"controller":"messages","named":[],"pass":[],"action":"index","plugin":null}}
There is no index ‘url’ in the array, so do you have any idea how to get those variables sent on the url that I posted using the attribute $params or something else?
EDIT :
i have tried this from the cookbook cakePHP2.0 :
<?php
// url is /posts/index?page=1&sort=title
$this->request->query['page'];
// You can also access it via array access
$this->request['url']['page'];
But i got the same Error :
Notice (8): Undefined index: page [APP\Controller\MessagesController.php, line 23]
Notice (8): Undefined index: page [APP\Controller\MessagesController.php, line 24]
Any ideas ??? how can i get the Variables sent on an url like this :
/posts/index?page=1&sort=title
There’s a new Request object in 2.0 that handles the query string among other things:
From the 2.0 Request object docs.