Re: save() not working

2011-12-19 Thread Geoff Douglas
Ok, so I see a few odd things going on here.

First, you say it's a cron job, but you are using a controller? Shouldn't 
you be using a Shell?

Second, set() is not a global function, it should be $this->set(). It's a 
method of the Controller class.

What fields does the table require... have you tried simply inserting a 
record by hand with the data you are trying to pass in?

-- 
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
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: save() not working

2011-12-18 Thread roundrightfarm
I figured it out. I was not thoroughly resetting my database records
to allow for proper testing so I was running the foreach on an empty
array.  Sorry to have wasted your time.

On Dec 18, 8:28 am, roundrightfarm  wrote:
> When I debug the save query, I get the same blank layout with no
> message, and nothing in error.log or debug.log, but no new records in
> the table.
>
> On Dec 18, 2:35 am, euromark  wrote:
>
>
>
>
>
>
>
> > yes, if there are no validation rules than there will be always an
> > empty result, of course.
> > did you debug the save query? does it return FAlSE?
>
> > On 18 Dez., 08:36, roundrightfarm  wrote:
>
> > > Yes, its set to 2
>
> > > On Dec 17, 11:23 pm, Geoff Douglas  wrote:
>
> > > > Do you have you core Configure debug level set to 2?
> > > > (In config/core.php)
>
> > > > Errors won't display if you don't have debug turned on.

-- 
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
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: save() not working

2011-12-18 Thread roundrightfarm
When I debug the save query, I get the same blank layout with no
message, and nothing in error.log or debug.log, but no new records in
the table.

On Dec 18, 2:35 am, euromark  wrote:
> yes, if there are no validation rules than there will be always an
> empty result, of course.
> did you debug the save query? does it return FAlSE?
>
> On 18 Dez., 08:36, roundrightfarm  wrote:
>
>
>
>
>
>
>
> > Yes, its set to 2
>
> > On Dec 17, 11:23 pm, Geoff Douglas  wrote:
>
> > > Do you have you core Configure debug level set to 2?
> > > (In config/core.php)
>
> > > Errors won't display if you don't have debug turned on.

-- 
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
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: save() not working

2011-12-18 Thread roundrightfarm
this is a cron job script which has no view, so it is expected that
the screen would be blank when i run it for testing.  The only way I
know it is not working properly is that there are no new records in
the database table.  Here is all the relevant code again.  I
simplified the naming of the table/model.

the table is named os_choices

here is my model:



here is my controller:



the script runs from the BoxesController, which var $uses =
array('OsChoice', etc.)  Here is the relevant snippet of boxes/
closeoutweek:

//now make a new record for the item in the os_choices table

$this->OsChoice->create();
$new_entry = array(
'OsChoice' => 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']
)
);
set('new_entry', $new_entry);
$this->OsChoice->save($new_entry);

setting the variable to the view is not effective either, so it seems
that $new_entry is not even getting made.  I have been stuck for a day
now trying to get this to record some data. Any ideas?








On Dec 17, 11:36 pm, roundrightfarm  wrote:
> Yes, its set to 2
>
> On Dec 17, 11:23 pm, Geoff Douglas  wrote:
>
>
>
>
>
>
>
> > Do you have you core Configure debug level set to 2?
> > (In config/core.php)
>
> > Errors won't display if you don't have debug turned on.

-- 
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
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: save() not working

2011-12-18 Thread euromark
yes, if there are no validation rules than there will be always an
empty result, of course.
did you debug the save query? does it return FAlSE?


On 18 Dez., 08:36, roundrightfarm  wrote:
> Yes, its set to 2
>
> On Dec 17, 11:23 pm, Geoff Douglas  wrote:
>
>
>
>
>
>
>
> > Do you have you core Configure debug level set to 2?
> > (In config/core.php)
>
> > Errors won't display if you don't have debug turned on.

-- 
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
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: save() not working

2011-12-17 Thread roundrightfarm
Yes, its set to 2

On Dec 17, 11:23 pm, Geoff Douglas  wrote:
> Do you have you core Configure debug level set to 2?
> (In config/core.php)
>
> Errors won't display if you don't have debug turned on.

-- 
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
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: save() not working

2011-12-17 Thread Geoff Douglas
Do you have you core Configure debug level set to 2?
(In config/core.php)

Errors won't display if you don't have debug turned on.

-- 
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
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: save() not working

2011-12-17 Thread roundrightfarm
When I try this, I still get an empty screen (except for my layout)
like before.  I tried making the second parameter to debug true with
the same result. So I'm not seeing the results anywhere of running

$var = $this->OsChoiceHistory->validationErrors;
debug($var);
die();

and

$var = $this->OsChoiceHistory->validationErrors;
debug($var, true);
die();

ditto for invalidFields()

does this mean there are no validation errors or invalid fields?  I'm
guessing this is the case because I have not set any validation rules
in the model.



On Dec 17, 9:51 am, euromark  wrote:
> I already gave you the answer in my previous post
> anyway:http://book.cakephp.org/2.0/en/development/debugging.html?highlight=d...
>
> for starters you can simply output and die:
>
> $var = $this->OsChoiceHistory->validationErrors;
> debug($var);
> die();
>
> On 17 Dez., 18:35, roundrightfarm  wrote:
>
>
>
>
>
>
>
> > did you try to debug     $this->OsChoiceHistory->validationErrors or
> >   $this->OsChoiceHistory->invalidFields()
>
> > how do I do this? and where do I go to see the results?
>
> > Thanks
>
> > On Dec 17, 9:26 am, euromark  wrote:
>
> > > 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  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
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: save() not working

2011-12-17 Thread euromark
I already gave you the answer in my previous post
anyway:
http://book.cakephp.org/2.0/en/development/debugging.html?highlight=debugging

for starters you can simply output and die:

$var = $this->OsChoiceHistory->validationErrors;
debug($var);
die();


On 17 Dez., 18:35, roundrightfarm  wrote:
> did you try to debug     $this->OsChoiceHistory->validationErrors or
>   $this->OsChoiceHistory->invalidFields()
>
> how do I do this? and where do I go to see the results?
>
> Thanks
>
> On Dec 17, 9:26 am, euromark  wrote:
>
>
>
>
>
>
>
> > 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  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
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: save() not working

2011-12-17 Thread roundrightfarm
did you try to debug     $this->OsChoiceHistory->validationErrors or  
  $this->OsChoiceHistory->invalidFields()

how do I do this? and where do I go to see the results?

Thanks





On Dec 17, 9:26 am, euromark  wrote:
> 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  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
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: save() not working

2011-12-17 Thread euromark
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  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
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: save not working

2010-10-06 Thread huoxito
try this to see if its a valitation problem:

if ( $this->Host->save($this->data)  ){
 // it saved
}else{
echo $errors = $this->ModelName->invalidFields();
}

or maybe some wrong field name you got in your array



On 5 out, 10:15, james  wrote:
> I'm trying to run a save on certain fields from my model and for some
> reason it isnt working -
>
> similarly to an edit im calling
>
> $this->Host->save($this->data)
>
> and the array in $this->data looks like
>
> Array
> (
>     [Host] => Array
>         (
>             [web] => 25
>             [prev_cost_of_sale] =>
>             [extras] =>
>             [price_A4s] =>
>             [previous_price_A4s] =>
>             [previous_adverts] =>
>             [previous_appts] =>
>         )
>
> )
>
> can anyone see what im doing wrong?
>
> thanks

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


Re: save not working

2010-10-05 Thread Jeremy Burns | Class Outfit
See the guide: http://book.cakephp.org/view/1031/Saving-Your-Data

save(array $data = null, boolean $validate = true, array $fieldList = array())

Jeremy Burns
Class Outfit

jeremybu...@classoutfit.com
http://www.classoutfit.com

On 5 Oct 2010, at 14:32, james wrote:

> Following on from this - it was a validation error since i was only
> updating half of the fields the validation rules were not being
> satisfied. So as part of that does anyone know how to disable the
> validation on a model before a save?
> 
> On 5 Oct, 14:15, james  wrote:
>> I'm trying to run a save on certain fields from my model and for some
>> reason it isnt working -
>> 
>> similarly to an edit im calling
>> 
>> $this->Host->save($this->data)
>> 
>> and the array in $this->data looks like
>> 
>> Array
>> (
>> [Host] => Array
>> (
>> [web] => 25
>> [prev_cost_of_sale] =>
>> [extras] =>
>> [price_A4s] =>
>> [previous_price_A4s] =>
>> [previous_adverts] =>
>> [previous_appts] =>
>> )
>> 
>> )
>> 
>> can anyone see what im doing wrong?
>> 
>> thanks
> 
> 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

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


Re: save not working

2010-10-05 Thread james
Following on from this - it was a validation error since i was only
updating half of the fields the validation rules were not being
satisfied. So as part of that does anyone know how to disable the
validation on a model before a save?

On 5 Oct, 14:15, james  wrote:
> I'm trying to run a save on certain fields from my model and for some
> reason it isnt working -
>
> similarly to an edit im calling
>
> $this->Host->save($this->data)
>
> and the array in $this->data looks like
>
> Array
> (
>     [Host] => Array
>         (
>             [web] => 25
>             [prev_cost_of_sale] =>
>             [extras] =>
>             [price_A4s] =>
>             [previous_price_A4s] =>
>             [previous_adverts] =>
>             [previous_appts] =>
>         )
>
> )
>
> can anyone see what im doing wrong?
>
> thanks

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


Re: save() not working

2007-08-04 Thread pbland

Adding return true did it!! THANK YOU!

I really appreciate the help Jon and francky06l.



On Aug 4, 1:02 pm, francky06l <[EMAIL PROTECTED]> wrote:
> well spotted Jon :-)
>
> On Aug 4, 7:15 pm, "Jon Bennett" <[EMAIL PROTECTED]> wrote:
>
> > > - Comment your beforeSave function
> > > - code $this->Account->save($this->data['Account'], null, false);
>
> > the problem lies with your beforeSave method, it doesn't return true,
> > so Model->save() is never called.
>
> > add return true; to the bottom of your beforeSave method and it should be 
> > fine.
>
> > pretty sure the manual says about this.
>
> > hth
>
> > jon
>
> > --
>
> > jon bennett
> > w:http://www.jben.net/
> > iChat (AIM): jbendotnet Skype: jon-bennett


--~--~-~--~~~---~--~~
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: save() not working

2007-08-04 Thread francky06l

well spotted Jon :-)

On Aug 4, 7:15 pm, "Jon Bennett" <[EMAIL PROTECTED]> wrote:
> > - Comment your beforeSave function
> > - code $this->Account->save($this->data['Account'], null, false);
>
> the problem lies with your beforeSave method, it doesn't return true,
> so Model->save() is never called.
>
> add return true; to the bottom of your beforeSave method and it should be 
> fine.
>
> pretty sure the manual says about this.
>
> hth
>
> jon
>
> --
>
> jon bennett
> w:http://www.jben.net/
> iChat (AIM): jbendotnet Skype: jon-bennett


--~--~-~--~~~---~--~~
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: save() not working

2007-08-04 Thread Jon Bennett

> - Comment your beforeSave function
> - code $this->Account->save($this->data['Account'], null, false);

the problem lies with your beforeSave method, it doesn't return true,
so Model->save() is never called.

add return true; to the bottom of your beforeSave method and it should be fine.

pretty sure the manual says about this.

hth

jon


-- 

jon bennett
w: http://www.jben.net/
iChat (AIM): jbendotnet Skype: jon-bennett

--~--~-~--~~~---~--~~
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: save() not working

2007-08-04 Thread francky06l

Well, I really do not see why it does not save.

Just for a try :

- Comment your beforeSave function
- code $this->Account->save($this->data['Account'], null, false);

On Aug 4, 6:01 pm, pbland <[EMAIL PROTECTED]> wrote:
> I added a row in the table and added this in the controller:
>
> function create() {
> if (empty($this->data)) {
> // no error message
> $this->set('error', false);
> $dat = $this->Account->findAll();
> pr($dat);
> // display the form to create account
> $this->render();
> }
> else { ...
>  }
>
> }
>
> and I see this when I open the page:
>
> Array
> (
> [0] => Array
> (
> [Account] => Array
> (
> [id] => 1
> [first_name] => Jane
> [last_name] => Doe
> [created] => 2007-08-04 10:55:40
> [modified] => 2007-08-04 10:55:40
> )
> )
> )
>
> So I can connect to the database and retrieve data. Just can't
> save. ???
>
> Thanks,
> Paul


--~--~-~--~~~---~--~~
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: save() not working

2007-08-04 Thread pbland

I added a row in the table and added this in the controller:

function create() {
if (empty($this->data)) {
// no error message
$this->set('error', false);
$dat = $this->Account->findAll();
pr($dat);
// display the form to create account
$this->render();
}
else { ...
 }
}

and I see this when I open the page:

Array
(
[0] => Array
(
[Account] => Array
(
[id] => 1
[first_name] => Jane
[last_name] => Doe
[created] => 2007-08-04 10:55:40
[modified] => 2007-08-04 10:55:40
)
)
)

So I can connect to the database and retrieve data. Just can't
save. ???

Thanks,
Paul


--~--~-~--~~~---~--~~
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: save() not working

2007-08-04 Thread pbland

I do have some simple validation in the model:

class Account extends AppModel {
var $name = 'Account';
var $validate = array(
'first_name' => VALID_NOT_EMPTY,
'last_name' => VALID_NOT_EMPTY
);

function beforeSave() {
uses('sanitize');
$sanitize = new Sanitize();
// Sanitize incoming data
$sanitize->clean($this->data);
}
}

My database.php is standard:

class DATABASE_CONFIG {
var $default = array(   'driver' => 'mysql',
'connect' => 
'mysql_connect',
'host' => 'localhost',
'login' => 'root',
'password' => 
'password',
'database' => 'ccmdb',
'prefix' => '');
}

I haven't retrieved data yet, as I first wanted to get the save to
work. I will add some data and do a findAll() and see what happens.

Thanks again.


--~--~-~--~~~---~--~~
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: save() not working

2007-08-04 Thread francky06l

Do you have validatin in model ? (I guess not), but maybe try
save($this->data['Account'], null, false). That sould skip the
validation  if any...

Apart from this action, are you able to set/retrieve the data from the
database (Even in other tables) ? Have got got an index action that
just does a findAll() ? Maybe there is a problem with the db
connection ?
What are the parameters in you database.php ?

On Aug 4, 4:34 pm, pbland <[EMAIL PROTECTED]> wrote:
> Thanks Jon Bennett and frankcy06l for the suggestions. I actually did
> have:
>
> if (empty($this->data)) {
>$this->render();
>
> }
>
> I didn't include it in my post, as I just wanted to show what I
> thought was relevant. Francky06l, in looking at the examples, I don't
> believe it's required to list Form and Html in the controller. I did
> replace the  with  and I added in
> the controller:
>
> // SAVE UNSUCESSFUL
> // validate model errors
> $this->validateErrors($this->Account);
> // pass data back to view
> $this->set('data', $this->data);
> // render form again
> $this->render();
>
> Unfortunately, it still doesn't work and I'm still not getting any
> error message. This is baffling. At first I had a lot of fields in the
> table, but I now have just first and last name to keep it simple. As
> the pr($this->data) shows, the Account array has data, but when the
> save() gets executed, I don't see any INSERT statement when I have
> debug set to 2. So it's like the save() doesn't even attempt to
> insert, but I don't know what else to check in my setup that could
> cause this.
>
> Thanks,
> Paul
>
> On Aug 4, 7:06 am, francky06l <[EMAIL PROTECTED]> wrote:
>
> > Few hints :
>
> > - in your controller you do not mention the helpers : Form, Html but
> > maybe the are in app_controller ?
> > - try to replace the  with 
> > >create(array('action' => 'create')); ?>
>
> > Hope this helps


--~--~-~--~~~---~--~~
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: save() not working

2007-08-04 Thread pbland

Thanks Jon Bennett and frankcy06l for the suggestions. I actually did
have:

if (empty($this->data)) {
   $this->render();
}

I didn't include it in my post, as I just wanted to show what I
thought was relevant. Francky06l, in looking at the examples, I don't
believe it's required to list Form and Html in the controller. I did
replace the  with  and I added in
the controller:

// SAVE UNSUCESSFUL
// validate model errors
$this->validateErrors($this->Account);
// pass data back to view
$this->set('data', $this->data);
// render form again
$this->render();

Unfortunately, it still doesn't work and I'm still not getting any
error message. This is baffling. At first I had a lot of fields in the
table, but I now have just first and last name to keep it simple. As
the pr($this->data) shows, the Account array has data, but when the
save() gets executed, I don't see any INSERT statement when I have
debug set to 2. So it's like the save() doesn't even attempt to
insert, but I don't know what else to check in my setup that could
cause this.

Thanks,
Paul

On Aug 4, 7:06 am, francky06l <[EMAIL PROTECTED]> wrote:
> Few hints :
>
> - in your controller you do not mention the helpers : Form, Html but
> maybe the are in app_controller ?
> - try to replace the  with 
> >create(array('action' => 'create')); ?>
>
> Hope this helps


--~--~-~--~~~---~--~~
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: save() not working

2007-08-04 Thread francky06l

Few hints :

- in your controller you do not mention the helpers : Form, Html but
maybe the are in app_controller ?
- try to replace the  with create(array('action' => 'create')); ?>

Hope this helps

On Aug 4, 4:49 am, pbland <[EMAIL PROTECTED]> wrote:
> Yes, here's my view:
>
> 
>  method="post" name="form">
> 
> Registration Information
> 
> First 
> Name*: $form->input('Account.first_name',
> array('class'=>'required','label'=>false,'size'=>'30'));?>
> Last 
> Name*: $form->input('Account.last_name',array('label'=>false,'size'=>30)); ?>
>
> 
> submit('Save') ?>
> 
> *Required field
> 
> 


--~--~-~--~~~---~--~~
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: save() not working

2007-08-04 Thread Jon Bennett

On 04/08/07, pbland <[EMAIL PROTECTED]> wrote:
>
> I've spent the last 2 days trying to get my save() to work with no
> luck. I've reviewed everything. Twice. I've checked this group for
> things to look for and everything looks correct. I've printed my model
> and it has the data:
>
> Array
> (
> [Account] => Array
> (
> [first_name] => Joe
> [last_name] => Tester
> )
> )
>
> Here's my database schema:
>
> CREATE TABLE accounts (
>  id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
>  first_name VARCHAR(30) NOT NULL,
>  last_name  VARCHAR(50) NOT NULL,
>  createdDATETIME DEFAULT NULL,
>  modified   DATETIME DEFAULT NULL)
>
> And my controller:
>
> class AccountsController extends AppController {
> var $name = 'Accounts';
> function create() {
>pr($this-data);
>if($this->Account->save($this->data)) {
>   echo 'save successful';
>else
>   echo 'no good';
> }
> }
>
> I don't have any redirects. I have debug at 2 and I don't see any
> INSERT statement, nor any error messages.
>
> Does anyone have some other things for me to check?

you need to check that the data's there before saving, have you gone
through the blog tutorial??

here's what you need anyway...

data))
{
$this->render();
}
// form has been submitted
else
{
// so attempt to save data
if ($this->Account->save($this->data))
{
// SAVE SUCCESSFUL
// inform user using cake's flash() method, see api for 
details
$this->flash('your data has been saved', '/');
}
else
{
// SAVE UNSUCESSFUL
// validate model errors
$this->validateErrors($this->Account);
// pass data back to view
$this->set('data', $this->data);
// render form again
$this->render();
}
}
}
}

?>

hth

jon


-- 

jon bennett
w: http://www.jben.net/
iChat (AIM): jbendotnet Skype: jon-bennett

--~--~-~--~~~---~--~~
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: save() not working

2007-08-03 Thread pbland

Yes, here's my view:




Registration Information

First 
Name*:input('Account.first_name',
array('class'=>'required','label'=>false,'size'=>'30'));?>
Last 
Name*:input('Account.last_name',array('label'=>false,'size'=>30)); ?
>

submit('Save') ?>

*Required field




--~--~-~--~~~---~--~~
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: save() not working

2007-08-03 Thread francky06l

I suppose you have a form submitting data to your create function ?
can you paste the form code (view) as well ?

On Aug 4, 4:07 am, pbland <[EMAIL PROTECTED]> wrote:
> Forgot to mention that I had cake 1.1 and it didn't work, so I
> upgraded to 1.2.0.5427 and still nothing.


--~--~-~--~~~---~--~~
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: save() not working

2007-08-03 Thread pbland

Forgot to mention that I had cake 1.1 and it didn't work, so I
upgraded to 1.2.0.5427 and still nothing.


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---