Odd.

What happens when you put the data straight into the table without Cake?

What are the data types of the fields? Do you have any validation rules in your 
PracticeInstance model? If not (I have experienced this before) it passes Cake 
validation but fails at the database level, tricking Cake into thinking that 
all is OK.

Are you running this from within the practice_instances controller? If so, try 
this:

if ($this->PracticeInstance->save($this->data['PracticeInstance'])):
        --do something
else:
        die(debug($this->PracticeInstance->validationErrors));
endif;

And see what pops up.

Jeremy Burns
jeremybu...@me.com

On 15 Apr 2010, at 05:56, Johnny Ferguson wrote:

> Hi,
> 
> I'm developing an app that has database relationships.
> 
> The table in question is like so:
> 
> tbl practice_instances
> id - int (primary)
> created - timestamp (default: null)
> modified - timestamp (default: null)
> timeminutes - int
> practice_session_id - int
> practice_item_id - int
> tempostart - int
> tempofinish - int
> 
> practice_session_id refers to an entry in the PracticeSession model
> (PracticeSession hasMany PracticeInstance)
> practice_item_id refers to an entry in the PracticeItem model
> (PracticeInstance belongsTo PracticeItem)
> 
> I have a form under /cakeRoot/practice_instances/add which accepts the
> following fields:
> 
> <?php
>       echo $form->create("PracticeInstance");
>       echo $form->input("timeminutes");
>       echo $form->input("practice_session_id");
>       echo $form->input("practice_item_id");
>       echo $form->input("tempostart");
>       echo $form->input("tempofinish");
>       echo $form->end("Create Practice Instance");
> ?>
> 
> When I submit the form, I can see in my controller dump:
> 
> [data] => Array
>                (
>                    [PracticeInstance] => Array
>                        (
>                            [timeminutes] => 20
>                            [practice_session_id] => 42
>                            [practice_item_id] => 3
>                            [tempostart] => 120
>                            [tempofinish] => 128
>                        )
> 
>                )
> 
> So everything is fine there, but when I look in my table, all the
> fields other than id, created, and modified are set to a value of 0.
> This is odd because cake is telling me that it saved $this->data, and
> as you can see, the values above are not zero. I have the feeling that
> I'm not understanding something about data relationships. Any idea why
> these fields are getting set to 0?
> 
> In the final application users won't really create PracticeInstances
> manually (it will be part of creating a PracticeSession), but I'd like
> to be able to add fields for testing.
> 
> Check out the new CakePHP Questions site http://cakeqs.org and help others 
> with their CakePHP related questions.
> 
> You received this message because you are subscribed to the Google Groups 
> "CakePHP" group.
> To post to this group, send email to cake-php@googlegroups.com
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
> http://groups.google.com/group/cake-php?hl=en
> 
> To unsubscribe, reply using "remove me" as the subject.

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to