Phalcon\Mvc\Url::get() append query params examples

Anybody know how to use the newly merged Phalcon\Mvc\Url::get() to append query params (https://github.com/phalcon/cphalcon/pull/877)? Usage example pls?



83.4k
$url = new Phalcon\Mvc\Url();
echo $url->get('/show/products', array('id' => 1, 'name' => 'Carrots')), "\n"; // /show/products?id=1&name=Carrots


30.1k

@Phalcon - since your example does not require any non-default routes to exist, I assumed that going to

http://..../show/products?id=1&name=Carrots

would make values of "id" and "name" available in Router or Dispatcher.

Unfortunately, that did not happen. What should I do to get those values, apart from fetching them from $_GET?

Thanks, Temuri



268

Since you have these in the Query string, you should use the $this->request object:

$this->request->getQuery('id', 'int');
$this->request->getQuery('name', 'string');