Wednesday, July 1, 2009

Cake Bug? Attempt to insert 12am time field results in null value

So I have a form that collects information about an tentative
appointment, including the start time and end time. Both the start
and end time fields are mysql columns of type time (not datetime).

My view file contains:

echo $form->input('starts',array('label'=>'starts','interval'=>30));
echo $form->input('ends',array('label'=>'ends','interval'=>30));

This renders correctly as two sets of dropdown fields, each with three
menus (hour, minute, and am/pm).

If I make a time selection that is midnight (12:00 am) then cake
generates the following sql:

INSERT INTO `inquiries` (`starts`, `ends`, `date`, `message`) VALUES
('18:00:00', NULL, 1, '2009-07-13', 'Testing the inquiry system')

As you can see, cake is translating the value of 12:00 am to NULL. I
assume this is because 12am is the same as 0, and 0 is being expressed
as NULL.

On submit, my controller has nothing fancy, just:

$this->Inquiry->create();
if($this->Inquiry->save($this->data))

It works perfectly fine for all other time values. It's just midnight
that messes it up.

Is this a bug? Or am I doing something wrong?
--~--~---------~--~----~------------~-------~--~----~
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+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

No comments: