Skip to content

Instantly share code, notes, and snippets.

View abacha's full-sized avatar

Adriano Bacha abacha

  • São Paulo, SP
  • 04:04 (UTC -03:00)
View GitHub Profile
CREATE TABLE `usuarios` (
`id` INT NOT NULL AUTO_INCREMENT ,
`nome` VARCHAR( 255 ) NOT NULL ,
PRIMARY KEY ( `id` )
)
Possible Models based on your current database:
1. Usuario
Enter a number from the list above, type in the name of another model, or 'q' to exit
[q] > 1
Would you like to supply validation criteria for the fields in your model? (y/n)
[y] > y
[...]
Field: nome
<?
function testAttributes() {
$this->assertFalse($this->Usuario->validates(), 'should be invalid');
$this->Usuario->set("nome", "adriano");
$this->assertTrue($this->Usuario->save(), 'should be valid');
}
?>
We couldn’t find that file to show.
<?
class Nome-do-modeloFixture extends CakeTestFixture {
var $name = 'Nome-do-modelo';
var $fields = array(
'id' => array('type'=>'integer', 'null' => false, 'default' => NULL, 'key' => 'primary'),
'descricao' => array('type'=>'string', 'null' => false, 'default' => NULL)
//aqui são listados todos os campos da tabela
);
var $records = array( //aqui vai os dados
<?
var $validate = array(
'nome' => array('notempty')
);
?>
We couldn’t find that file to show.
var $validate = array(
'rule' => array('custom', '/^[\x20-\x7E]+$/i'),
'required' => true
);
We couldn’t find that file to show.
<?
var $validate = array(
'rule' => array('custom', '/^.*$/'),
'required' => true
);
?>