Now I've tried.
the sql queries that ran were:
START TRANSACTION
INSERT INTO `posts` (`event_datetime`, `description_pt`,
`description_en`, `status`, `modified`, `created`) VALUES ('2011-06-07
23:10:00', 'desc pt', 'desc en', 1, '2011-06-08 08:20:28', '2011-06-08
08:20:28')
SELECT LAST_INSERT_ID() AS insertID
INSERT INTO `attachments` (`post_id`) VALUES (8)
SELECT LAST_INSERT_ID() AS insertID
COMMIT
So yes it added a record in attachments table with the post_id, but
it's not getting the data from $fakedata['Attachment']
On 8 Jun, 09:00, Jeremy Burns | Class Outfit
<[email protected]> wrote:
> Have you tried saveAll?
>
> Jeremy Burns
> Class Outfit
>
> [email protected]http://www.classoutfit.com
>
> On 8 Jun 2011, at 08:58, homem-arvore wrote:
>
>
>
>
>
>
>
> > Hi.
> > I've been banging my head on the walls for almost a day now and still
> > haven't understood what am I doing wrong
>
> > I've set up a test that I think should work but it doesn't:
>
> > $fakedata = array(
> > 'Post' => array(
> > 'event_datetime' => "2011-06-07 23:10:00", 'description_pt' =>
> > 'desc
> > pt', 'description_en' => 'desc en', 'status' => 1
> > ),
> > 'Attachment' => array(
> > array("post_id" => 500, 'dirname' => "dir", 'basename' =>
> > 'file1.png', 'category' => 'poster', 'order' => 0),
> > array("post_id" => 500, 'dirname' => "dir", 'basename' =>
> > 'file2.png', 'category' => 'poster', 'order' => 1),
> > array("post_id" => 500, 'dirname' => "dir", 'basename' =>
> > 'file3.png', 'category' => 'poster', 'order' => 2),
> > array("post_id" => 500, 'dirname' => "dir", 'basename' =>
> > 'file4.png', 'category' => 'poster', 'order' => 3),
> > array("post_id" => 500, 'dirname' => "dir", 'basename' =>
> > 'file5.png', 'category' => 'poster', 'order' => 4),
> > ));
>
> > shouldn't:
> > $this->Post->Attachment->save($fakedata);
>
> > just work?
>
> > It returns 1 but there's data being sent to the mysql database
>
> > My Post model has set up the Attachment as an hasMany relationship and
> > the Attachment model has a belongsto relationship to Post.
>
> > --
> > Our newest site for the community: CakePHP Video
> > Tutorialshttp://tv.cakephp.org
> > Check out the new CakePHP Questions sitehttp://ask.cakephp.organd help
> > others with their CakePHP related questions.
>
> > To unsubscribe from this group, send email to
> > [email protected] For more options, visit this group
> > athttp://groups.google.com/group/cake-php
--
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
[email protected] For more options, visit this group at
http://groups.google.com/group/cake-php