I need urgent help!  I'm a novice at Cake and I'm having trouble
getting a date saved in my SQL database.  I am trying to have the date
save automatically depending on which day a user clicks on on a
calendar to create a new event.  To do that, I added a parameter to my
"add" function called $event_date, which was passed in the URL in the
form YYYY-MM-DD, so my URL looks like www.site.com/events/add/2009-08-27
.  This is my function currently:

function add($event_date = null) {
            $this->Event->event_date = $event_date;
            $this->set('event_date',$event_date); //for use again in
view
            if (!empty($this->data)) {
               $year = substr($event_date,0,4); //I broke my parameter
down to use it in a unix time stamp.
               $month = substr($event_date,5,2);
               $day = substr($event_date,8,2);
               $str = mktime(0,0,0,$month,$day,$year);
               $v = date("Y-m-d",$str);

                $this->data['Event']['event_date'] = $v; //here is
where I think I have problems.
                        if ($this->Event->save($this->data)) {
                                $this->Session->setFlash('Your event has been 
saved.');
                                
$this->redirect(array('controller'=>'events','action' =>
'calendar'));
                                }
            }
        }

I know this code is probably horrible and passing the whole date in
one parameter is also not the best way to do things, but if anyone
could enlighten me as to what I'm doing wrong it'd be very much
appreciated!

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