Look at my last post here 
http://groups.google.com/group/cake-php/browse_thread/thread/b3ff9deff2d1ea1e

You probably need to do your 'save' then set the id from
getLastInsertedId() ...

On Dec 1, 9:12 pm, jsmale <[EMAIL PROTECTED]> wrote:
> Hi,
>
> After extensive reading, I've followed teknoid's example (http://
> teknoid.wordpress.com/2008/09/24/saving-extra-fields-in-the-join-table-
> for-habtm-models/) on how to save an extra field on a join table.
>
> Just one problem :( Here's the data array being saved:
> ------------------------------
> Array(
>     [Payment] => Array(
>             [registry_id] => 10
>             [name] =>
>             [email] =>
>             [message] =>
>             [method] =>
>             [amount] => 50
>         )
>     [ItemsPayment] => Array(
>             [0] => Array(
>                     [item_id] => 18
>                     [amount] => 50
>                 )
>             [1] => Array(
>                     [item_id] => 19
>                     [amount] => 35
>                 )
>         )
> )
>
> Related SQL:
> 1. START TRANSACTION
> 2. INSERT INTO `payments`
> (`registry_id`,`name`,`email`,`message`,`method`,`amount`) VALUES
> (10,'','','','','50')
> 3. SELECT LAST_INSERT_ID() AS insertID
> 4. INSERT INTO `items_payments` (`item_id`,`amount`,`payment_id`)
> VALUES (18,'50','')
> 5. INSERT INTO `items_payments` (`item_id`,`amount`,`payment_id`)
> VALUES (19,'35','')
> 6. SELECT LAST_INSERT_ID() AS insertID
> 7. COMMIT
> ------------------------------
>
> Problem is the payment_id field isn't being populated with the
> insertID.
>
> Related code from controller:
> $this->Payment->bindModel(array('hasMany'=>array('ItemsPayment')));
> $this->Payment->saveAll($this->data);
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to