Monday, February 28, 2011

Re: Can't Save to DB

On Feb 28, 2011, at 08:55, theweirdone wrote:

> So i've changed the save() to updateAll() with the following:
> if($this->Episode->updateAll( array('Episode.name' => $episode['name']), array('Episode.number' => $episode['number']), array('Episode.description' => $episode['description']), array('Episode.date' => $episode['date']), array('Episode.show_id' => $episode['show_id']))){
>
> Now I get an "SQL Error: 1054: Unknown column 'Stowaway' in 'field list'". The query that it shows is:
> Query: UPDATE `episodes` AS `Episode` LEFT JOIN `shows` AS `Show` ON (`Episode`.`show_id` = `Show`.`id`) SET `Episode`.`name` = Stowaway WHERE `Episode`.`number` = 17
>
> Is it because it's looking for an already existing entry? (not sure entry is the right word). Shouldn't the SQL query be ADD instead of UPDATE?
>
> I've tried using saveAll() too, but that has the same effect as save(). :-S

Er, sorry, for creating new records I meant saveAll(), not updateAll(). But I may have glanced at your code too quickly and not understood it.

Are you sure your data is in the right format? The data you showed in your daniweb forum post is not in the format shown here:

http://book.cakephp.org/view/1031/Saving-Your-Data

In particular, you need the array key that says what the model name is.


--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

No comments: