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
<h3>Inscrição</h3> | |
<?php echo $this->Form->create('Inscricao', array('action' => 'inscrever')); ?> | |
<?php echo $this->Form->input('nome'); ?> | |
<?php echo $this->Form->input('email'); ?> | |
<?php echo $this->Form->input('telefone'); ?> | |
<?php echo $this->Form->input('endereco'); ?> | |
<?php echo $this->Form->submit('Salvar'); ?> | |
<?php echo $this->Form->end(); ?> |
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 | |
class InscricoesController extends AppController { | |
public $name = 'Inscricoes'; | |
public $use = array('Inscricao'); | |
public function inscrever() { | |
// Se recebemos dados do formulário | |
if (!empty($this->data)) { | |
// Tenta salvar esses dados | |
$this->Inscricao->save($this->data); |
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 | |
class Noticia extends AppModel { | |
public $name = 'Noticia'; | |
public $validate = array( | |
'titulo' => array( | |
'rule' => 'notEmpty', | |
'message' => 'Preencha o título' | |
), |
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 | |
class Usuario extends AppModel { | |
public $name = 'Usuario'; | |
public $validate = array( | |
'twitter' => array( | |
'rule' => 'perfilTwitter', | |
'message' => 'Perfil do Twitter inválido' | |
) |
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 | |
class NoticiasController extends AppController { | |
public function index() { | |
// Parâmetros de consulta | |
$params = array( | |
'conditions' => array('Noticia.active' => true), | |
'order' => array('Noticia.created' => 'DESC'), | |
'limit' => 5 | |
); |
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 | |
$params = array( | |
'conditions' => array('Model.campo' => 'valor'), // Condições | |
'recursive' => 1, // Nível de recursividade | |
'fields' => array('Model.campo1', 'Model.campo2'), // Campos retornados | |
'order' => array('Model.created', 'Model.campo3 DESC'), // Ordem | |
'group' => array('Model.field'), // GROUP BY | |
'limit' => n, // Limite de resultados | |
'page' => n, // Página |
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 | |
$email = '[email protected]'; | |
$params = array( | |
'conditions' => array( | |
'Usuario.email' => $email, | |
'Usuario.idade >=' => 18 | |
), | |
'order' => array('Usuario.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
SELECT Usuario.* FROM `usuarios` AS Usuario WHERE Usuario.`email` = '[email protected]' AND Usuario.`idade` >= 18 ORDER BY Usuario.nome ASC |
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 | |
public function view($titulo, $id) { | |
$this->Noticia->id = $id; | |
$dados = $this->Noticia->read(); | |
$this->set('noticia', $dados); | |
} |
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
'email' => array( | |
array( | |
'rule' => 'notEmpty', | |
'message' => 'Não pode ser vazio!' | |
), | |
array( | |
'rule' => 'email', | |
'message' => 'E-mail inválido' | |
) | |
) |