This file contains hidden or 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 `usuarios` ( | |
| `id` INT NOT NULL AUTO_INCREMENT , | |
| `nome` VARCHAR( 255 ) NOT NULL , | |
| PRIMARY KEY ( `id` ) | |
| ) |
This file contains hidden or 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
| 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 |
This file contains hidden or 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
| <? | |
| function testAttributes() { | |
| $this->assertFalse($this->Usuario->validates(), 'should be invalid'); | |
| $this->Usuario->set("nome", "adriano"); | |
| $this->assertTrue($this->Usuario->save(), 'should be valid'); | |
| } | |
| ?> |
This file contains hidden or 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
| <? | |
| 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 |
This file contains hidden or 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
| <? | |
| var $validate = array( | |
| 'nome' => array('notempty') | |
| ); | |
| ?> |
This file contains hidden or 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
| var $validate = array( | |
| 'rule' => array('custom', '/^[\x20-\x7E]+$/i'), | |
| 'required' => true | |
| ); |
This file contains hidden or 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
| <? | |
| var $validate = array( | |
| 'rule' => array('custom', '/^.*$/'), | |
| 'required' => true | |
| ); | |
| ?> |