1.1.17.5612 / multiple save misbehaviour !?

2007-10-23 Thread flipcode


this code does not not behave as expected:

$this-save($entry1,false,null);
$this-save($entry2,false,null);

actually the second save becomes an UPDATE instead of an INSERT (which
i would expect).

it has to be changed to

$this-save($entry1,false,null);
$this-id = false;
$this-save($entry2,false,null);

when i look at the model save function i see some cleanup code at the
end of it ... however the stored id leads to an implicit sql UPDATE.

is this the intended behaviour?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP 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
-~--~~~~--~~--~--~---



Re: 1.1.17.5612 / multiple save misbehaviour !?

2007-10-23 Thread Grant Cox

Yes, it is intended.

In Cake 1.2.x you should always use $this-create() before a save that
is intended to be an INSERT - I'm not sure if this function exists in
1.1.x.  But setting $this-id to false or null is the basic
requirement.


On Oct 24, 2:43 am, flipcode [EMAIL PROTECTED] wrote:
 this code does not not behave as expected:

 $this-save($entry1,false,null);
 $this-save($entry2,false,null);

 actually the second save becomes an UPDATE instead of an INSERT (which
 i would expect).

 it has to be changed to

 $this-save($entry1,false,null);
 $this-id = false;
 $this-save($entry2,false,null);

 when i look at the model save function i see some cleanup code at the
 end of it ... however the stored id leads to an implicit sql UPDATE.

 is this the intended behaviour?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP 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
-~--~~~~--~~--~--~---



Re: 1.1.17.5612 / multiple save misbehaviour !?

2007-10-23 Thread Freddy Krueger
grant,

thanks for mentioning the create() function ... i did not the like the
$this-id hack :D

cheers.

2007/10/23, Grant Cox [EMAIL PROTECTED]:


 Yes, it is intended.

 In Cake 1.2.x you should always use $this-create() before a save that
 is intended to be an INSERT - I'm not sure if this function exists in
 1.1.x.  But setting $this-id to false or null is the basic
 requirement.


 On Oct 24, 2:43 am, flipcode [EMAIL PROTECTED] wrote:
  this code does not not behave as expected:
 
  $this-save($entry1,false,null);
  $this-save($entry2,false,null);
 
  actually the second save becomes an UPDATE instead of an INSERT (which
  i would expect).
 
  it has to be changed to
 
  $this-save($entry1,false,null);
  $this-id = false;
  $this-save($entry2,false,null);
 
  when i look at the model save function i see some cleanup code at the
  end of it ... however the stored id leads to an implicit sql UPDATE.
 
  is this the intended behaviour?


 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP 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
-~--~~~~--~~--~--~---