Skip to content

Instantly share code, notes, and snippets.

@ogabrielsantos
Created October 12, 2014 08:45
Show Gist options
  • Select an option

  • Save ogabrielsantos/084ee93474c6f5ce9971 to your computer and use it in GitHub Desktop.

Select an option

Save ogabrielsantos/084ee93474c6f5ce9971 to your computer and use it in GitHub Desktop.
POST/REDIRECT/GET para uso no CakePHP
<?php
// POST
if ($this->request->is('post') || $this->request->is('put')) {
$uniqId = uniqid();
$this->Session->write('Search.' . $uniqId, json_encode($this->request->data));
// REDIRECT
return $this->redirect('index/search:' . $uniqId);
// GET
} elseif (isset($this->request->params['named']['search'])) {
$data = $this->Session->read('Search.' . $this->request->params['named']['search']);
if (!$data) {
return $this->redirect('index');
}
$this->request->data = json_decode($data, true);
// Lógica de paginação dos resultados
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment