did you try to debug
$this->OsChoiceHistory->validationErrors
or
$this->OsChoiceHistory->invalidFields()
?
they should contain an array of fields that probably made sure the
save was unsuccessfull
it would also be wise to debug the result of the last save()
$res = $this->OsChoiceHistory->save($new_entry);
debug($res);
On 17 Dez., 18:17, roundrightfarm <[email protected]> wrote:
> I can't create a new record in my database table.
>
> Here is the code I am using
>
> [code]foreach($boxes as $box) {
> //check and see if the box's owner has any optional
> shares
> //if they do, add the product to the boxes item table
> so it will be
> included with their order list and aggregate product order totals
> $optional_share_users =
> $this->OptionalShareUser->find('all');
> foreach ($optional_share_users as $share_user){
> if ($box['Box']['user_id'] ==
> $share_user['OptionalShareUser']
> ['user_id']){
> $this->BoxesItem->read(null,
> $box['Box']['id']);
> $this->BoxesItem->create();
> $new_optional_share_item = array(
> 'BoxesItem' => array(
> 'box_id' =>
> $box['Box']['id'],
> 'item_id' =>
> $share_user['OptionalShareUser']
> ['current_product_id']
> )
> );
>
> $this->BoxesItem->save($new_optional_share_item);
>
> //now make a new record for the item in the
> os_choice_history
> table
>
> $this->OsChoiceHistory->create();
> $new_entry = array(
> 'OsChoiceHistory' => array(
> 'week_id' =>
> $current_shown_week_id,
> 'optional_share_id'
> => $share_user['OptionalShareUser']
> ['share_id'],
> 'user_id' =>
> $share_user['OptionalShareUser']['user_id'],
> 'item_id' =>
> $share_user['OptionalShareUser']
> ['current_product_id']
> )
> );
>
> $this->OsChoiceHistory->save($new_entry);
>
> }
> }
>
> [/code]
>
> This code runs without any errors, and the first half works to save to
> the boxes_items table, but the second half leaves the
> os_choice_histories table unchanged. Any ideas what I'm missing here
--
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