Last active
August 29, 2015 14:21
-
-
Save EOM/4e7f5a410130f71ed6b5 to your computer and use it in GitHub Desktop.
Personalizar los datos del paginador de CakePHP con la union de datos por medio de JOINS muy simple de implementar
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Application level Controller | |
*/ | |
App::uses('Controller', 'Controller'); | |
// Controller Ejemplo | |
class AppController extends Controller { | |
public function index(){ | |
$this->SenasaPedidosFacturadosSds->recursive = -1; | |
// Filtro | |
$where = array( | |
'joins' => array( | |
array( | |
'table' => 'usuarios', | |
'alias' => 'Usuarios', | |
'type' => 'INNER', | |
'conditions' => array( | |
'Usuarios.usuario_id = SenasaPedidosFacturadosSds.usuarios_id' | |
) | |
), | |
array( | |
'table' => 'senasa_pedidos', | |
'alias' => 'SenasaPedidos', | |
'type' => 'INNER', | |
'conditions' => array( | |
'SenasaPedidos.id = SenasaPedidosFacturadosSds.senasa_pedidos_id' | |
) | |
), | |
array( | |
'table' => 'clientes', | |
'alias' => 'Clientes', | |
'type' => 'INNER', | |
'conditions' => array( | |
'Clientes.id_cliente = SenasaPedidos.clientes_id' | |
) | |
), | |
), | |
'fields'=>array( | |
'SenasaPedidosFacturadosSds.*', | |
'Usuarios.usuario_id', | |
'Usuarios.apellido_nombre', | |
'Usuarios.senasa_establecimientos_id', | |
'Clientes.id_cliente', | |
'Clientes.consolida_doc_sanitaria', | |
'Clientes.requiere_senasa', | |
'Clientes.razon_social', | |
'SenasaPedidos.id', | |
'SenasaPedidos.domicilio_entrega', | |
'SenasaPedidos.sds', | |
'SenasaPedidos.pt_ptr' | |
), | |
'conditions'=>array( | |
'Clientes.requiere_senasa'=>1 | |
), | |
'order' => 'SenasaPedidosFacturadosSds.created DESC', | |
'limit'=>100 | |
); | |
// Get Datos | |
$this->paginate = $where; | |
// Get datos | |
$data = $this->Paginator->paginate(); | |
// Debug Out | |
exit(debug($data)); | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment