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/Model/Article.php | |
class Article extends AppModel | |
{ | |
public $hasMany = 'Comment'; | |
} |
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/Model/Comment.php | |
class Comment extends AppModel | |
{ | |
public $belongsTo = 'Article'; | |
} |
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 `articles` ( | |
`id` int(11) unsigned NOT NULL AUTO_INCREMENT, | |
`title` varchar(100) NOT NULL, | |
PRIMARY KEY (`id`) | |
) ENGINE=InnoDB DEFAULT CHARSET=utf8; |
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 `comments` ( | |
`id` int(11) unsigned NOT NULL AUTO_INCREMENT, | |
`comment` varchar(100) NOT NULL, | |
`article_id` int(11) unsigned NOT NULL, | |
PRIMARY KEY (`id`), | |
KEY `FK_COMMENTS_ARTICLE_ID` (`article_id`), | |
CONSTRAINT `FK_COMMENTS_ARTICLE_ID` FOREIGN KEY (`article_id`) REFERENCES `articles` (`id`) ON UPDATE NO ACTION | |
) ENGINE=InnoDB DEFAULT CHARSET=utf8; |
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/Model/Comment.php | |
class Comment extends AppModel | |
{ | |
public $belongsTo = array( | |
'Article' => array( | |
'foreign_key' => 'post_id' | |
) | |
); | |
} |
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/Controller/ArticlesController.php | |
class ArticlesController extends AppController | |
{ | |
public $scaffold; | |
} |
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/Model/Article.php | |
class Article extends AppModel | |
{ | |
public $hasMany = array( | |
'Comment' | |
); | |
public $validate = array( | |
'title' => array( | |
'rule' => array('notEmpty'), |
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
# /app/Console/cake | |
cake bake all |
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 `books` ( | |
`id` int( 11 ) NOT NULL AUTO_INCREMENT , | |
`isbn` varchar( 13 ) NOT NULL , | |
`title` varchar( 64 ) NOT NULL , | |
`description` text NOT NULL , | |
`author_id` int( 11 ) NOT NULL, | |
PRIMARY KEY (`id`) | |
); |
OlderNewer