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 | |
$estados = $this->User->find('list',array( 'fields'=>'estado', 'group'=>'estado', 'order'=>'estado ASC', 'recursive'=>-1 )); | |
foreach($estados as $id=>$nome){ | |
echo $this->Html->link( $nome, array( 'controller'=>'users', 'action'=>'index', 'estado'=>$nome) ); | |
} | |
$names = $this->User->find('list',array( 'fields'=>'name', 'group'=>'name', 'order'=>'name ASC', 'recursive'=>-1 )); | |
foreach($names as $id=>$nome){ | |
echo $this->Html->link( $nome, array( 'controller'=>'users', 'action'=>'index', 'name'=>$nome) ); | |
} |
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
CREATE TABLE users ( | |
id INT UNSIGNED NOT NULL AUTO_INCREMENT, | |
group_id INT UNSIGNED NOT NULL, | |
name VARCHAR(200) NOT NULL, | |
username VARCHAR(20) NOT NULL, | |
estado VARCHAR(40) NOT NULL, | |
active TINYINT(1) NOT NULL DEFAULT 1, | |
PRIMARY KEY(id), | |
FOREIGN KEY(group_id) REFERENCES groups(id), | |
UNIQUE(username) |
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
public class Cliente { | |
private Integer codCliente; | |
private String nome; | |
private String telefone; | |
private String endereco; | |
private String dataNascimento; | |
private String dataCadastro; | |
// Construtores |
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 | |
App::uses('AppController', 'Controller'); | |
/** | |
* Users Controller | |
* | |
* @property User $User | |
*/ | |
class GeoController extends AppController { | |
public $components = array('RequestHandler','Json'); |
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 | |
/** | |
* add method | |
* | |
* @return void | |
*/ | |
public function add() { | |
if ($this->request->is('post')) { | |
$this->request->data['Page']['created'] = date('Y-m-d H:i:s'); |
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 | |
App::uses('AppModel', 'Model'); | |
/** | |
* Projeto Model | |
* | |
*/ | |
class Projeto extends AppModel { | |
/** | |
* Display field | |
* |
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 | |
App::uses('AppModel', 'Model'); | |
/** | |
* Cidade Model | |
* | |
*/ | |
class Cidade extends AppModel { | |
var $name = 'Cidade'; | |
var $displayField = 'nome'; | |
var $useDbConfig = 'geobase'; |
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 | |
Router::connect( | |
'/projetos/:categoria' , | |
array('controller' => 'projetos', 'action' => 'index'), // Local à ser redirecionado | |
array('pass' => array('categoria'), 'categoria' => '[a-zA-Z-0-9_]*') | |
); | |
Router::connect( | |
'/projetos/:categoria/:codigo' , | |
array('controller' => 'projetos', 'action' => 'view'), // Local à ser redirecionado | |
array('pass' => array('codigo'), 'categoria' => '[a-zA-Z-0-9_]*', 'codigo' => '[a-zA-Z-0-9_]{7}') |
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 | |
/* | |
** Função para validação personalizada | |
** @link http://snook.ca/archives/cakephp/multiple_validation_sets_cakephp | |
*/ | |
function validates($options = array()) { | |
// copy the data over from a custom var, otherwise | |
$actionSet = 'validate' . Inflector::camelize(Router::getParam('action')); | |
if (isset($this->validationSet)) { | |
$temp = $this->validate; |
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 | |
$highlightCategories = array(1,2,3,4,5,6,7,8,9); // IDs das Categorias selecionadas | |
// Estrutura principal da consulta | |
$sql = ""; | |
$sqlBody = " (SELECT `Noticia`.`id` as `Noticia.id`, `Noticia`.`categoria_id` as `Noticia.categoria_id`, `Noticia`.`titulo` as `Noticia.titulo`, `Noticiascategoria`.`id` as `Noticiascategoria.id`, `Noticiascategoria`.`titulo` as `Noticiascategoria.titulo`, `Noticiascategoria`.`slug` as `Noticiascategoria.slug` FROM `noticias` AS `Noticia` LEFT JOIN `noticiascategorias` AS `Noticiascategoria` ON (`Noticia`.`categoria_id` = `Noticiascategoria`.`id`) WHERE `Noticia`.`status` = '1' AND "; | |
// Gera a consulta para cada categoria | |
foreach($highlightCategories as $categoria){ | |
$sql .= $sqlBody." `Noticia`.`destaque` = '1' AND `Noticia`.`categoria_id` = '".$categoria."' ORDER BY `Noticia`.`id` DESC LIMIT 2) UNION "; |