cake automagically handles fields created & modified (or updated) if present.
Personally in my set up I have found that created gets set to 0000-00-00 and modfied gets updated correctly, perhaps this is due to my own foul up - its some I plan to look into but http://book.cakephp.org/ja/view/69/created-modified-or-updated 2008/4/28 djspark <[EMAIL PROTECTED]>: > > Would you suggest these be instead named: modified & created ? > > > On Apr 28, 2:43 pm, "Sam Sherlock" <[EMAIL PROTECTED]> wrote: > > also I believe your missing out on some autmagic benefits by using > > date_created and date_modified > > > > 2008/4/28 Sam Sherlock <[EMAIL PROTECTED]>: > > > > > try > > > > > $this->BlogPost->read(null, $BlogPostId) > > > > > in place of > > > > > $this->BlogPost->read() > > > > > hth - S > > > > > 2008/4/28 djspark <[EMAIL PROTECTED]>: > > > > > > Hello, > > > > > > I've decided to take a stab at developing with CakePHP instead of > re- > > > > inventing the wheel every time I develop a site. So far I've been > very > > > > impressed with everything it can do, and how great the organization > > > > is. > > > > > > Currently I'm trying to do the blog example, however with my own > > > > table. Reason being is anyone can copy/paste code, however I'd like > to > > > > really understand the "why". > > > > > > I'm up to the point where I implement the the ability to view a blog > > > > post within a view and I'm having some troubles. > > > > > > First off, here's my table: > > > > [code] > > > > CREATE TABLE IF NOT EXISTS `supa_supa`.`blog_posts` ( > > > > `blog_posts_id` BIGINT(12) NOT NULL , > > > > `blog_id` BIGINT(12) NOT NULL , > > > > `author_id` BIGINT(12) NULL , > > > > `author_type` VARCHAR(45) NULL , > > > > `date_created` DATETIME NULL , > > > > `date_modified` DATETIME NULL , > > > > `title` VARCHAR(128) NULL , > > > > `description` VARCHAR(256) NULL , > > > > `header` TEXT NULL , > > > > `body` TEXT NULL , > > > > `footer` TEXT NULL , > > > > PRIMARY KEY (`blog_posts_id`) ; > > > > [/code] > > > > > > Here's my function from my blog_posts_controller.php > > > > [code] > > > > function view($BlogPostId = null) { > > > > $this->BlogPost->BlogPostId = $BlogPostId; > > > > $this->set('BlogPost', $this->BlogPost->read()); > > > > } > > > > [/code] > > > > > > And finally my view: > > > > [code] > > > > <h1><?php echo $BlogPost['BlogPost']['title']?></h1> > > > > <p><small>Created: <?php echo > $BlogPost['BlogPost']['date_created']?></ > > > > small></p> > > > > <p><?php echo $BlogPost['BlogPost']['body']?></p> > > > > [/code] > > > > > > Now I'm receiving the following error, and no matter how I change > > > > variable names in the view() function the error is constant. > > > > > > Warning (512): SQL Error: 1054: Unknown column 'BlogPost.id' in > 'where > > > > clause' [CORE/cake/libs/model/datasources/dbo_source.php, line 440] > > > > > > The query it's attempting is: > > > > > > SELECT `BlogPost`.`blog_posts_id`, `BlogPost`.`blog_id`, > > > > `BlogPost`.`author_id`, `BlogPost`.`author_type`, > > > > `BlogPost`.`date_created`, `BlogPost`.`date_modified`, > > > > `BlogPost`.`title`, `BlogPost`.`description`, `BlogPost`.`header`, > > > > `BlogPost`.`body`, `BlogPost`.`footer` FROM `blog_posts` AS > `BlogPost` > > > > WHERE `BlogPost`.`id` = 1 LIMIT 1 > > > > > > Have I committed a naming faux pas by having my PK blog_posts_id ? > The > > > > index that uses findAll() works like a charm, it's just this view > that > > > > I can't seem to get working. > > > > > > Thanks, > > > > Mark > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---