How to debug when CakePHP Model::save() doesn't attempt an INSERT

Posted by RyOnLife on Stack Overflow See other posts from Stack Overflow or by RyOnLife
Published on 2009-02-19T18:16:51Z Indexed on 2010/06/17 9:43 UTC
Read the original article Hit count: 295

Filed under:

I am having a bear of a time saving the simplest record from a model called ItemView:

if($this->save($this->data)) {
  echo 'worked';
} else {
  echo 'failed';
}

Where $this->data is:

Array
(
    [ItemView] => Array
        (
            [list_id] => 1
            [user_id] => 1
        )
)

And my table is:

CREATE TABLE IF NOT EXISTS `item_views` (
  `id` int(11) NOT NULL auto_increment,
  `list_id` int(11) NOT NULL,
  `user_id` int(11) default NULL,
  `user_ip` int(10) unsigned default NULL,
  `created` datetime NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED AUTO_INCREMENT=1 ;

Looking at the query dump in debug mode, Cake isn't even attempting an INSERT, so I have no idea how to debug.

Any help would be appreciated.

© Stack Overflow or respective owner

Related posts about cakephp