#5644: Model->save() on Models/edit zeroes the `seconds` in a datetime/timestamp
field.
----------------------------------------------------------+-----------------
Reporter: sonnygauran | Type: Bug
Status: new | Priority:
Medium
Milestone: 1.2.x.x | Component:
Controller
Version: RC3 | Severity:
Major
Keywords: seconds date time datetime timestamp save | Php_version: n/a
Cake_version: 1.2.0.7692 RC3 |
----------------------------------------------------------+-----------------
Steps to replicate:
* The model: A model with a datetime/timestamp field
* The controller: Edit the controller, and
* Sample and Result: Notice the 00 now on the seconds.
Pretty much, this was all from `cake bake`.
Shouldn't the 'seconds' be untouched?
But, as for reference:
== The model ==
{{{
create table messages (
`id` char(36) not null
, `created` timestamp not null
, `msg` char(400)
)engine=myisam;
}}}
== The controller ==
{{{
<?php
class MessagesController extends AppController {
var $name = 'Messages';
function edit($id = null) {
if (!$id && empty($this->data)) {
$this->Session->setFlash(__('Invalid Message',
true));
$this->redirect(array('action'=>'index'));
}
if (!empty($this->data)) {
if ($this->Message->save($this->data)) {
$this->Session->setFlash(__('The Message
has been saved', true));
$this->redirect(array('action'=>'index'));
} else {
$this->Session->setFlash(__('The Message
could not be saved. Please, try again.', true));
}
}
if (empty($this->data)) {
$this->data = $this->Message->read(null, $id);
}
}
}
?>
}}}
and it's view:
{{{
<div class="messages form">
<?php echo $form->create('Message');?>
<fieldset>
<legend><?php __('Edit Message');?></legend>
<?php
echo $form->input('id');
echo $form->input('created');
echo $form->input('msg');
?>
</fieldset>
<?php echo $form->end('Submit');?>
</div>
}}}
== Sample and Result ==
Before edit:
{{{
Array (
[Message] => Array (
[id] => 48fdffe0-9794-4eec-af49-1975c0a80064
[created] => 2008-10-22 02:49:29
[msg] => Some message
)
)
}}}
and after:
{{{
Array (
[Message] => Array (
[id] => 48fdffe0-9794-4eec-af49-1975c0a80064
[created] => 2008-10-22 02:49:00
[msg] => Some message
)
)
}}}
--
Ticket URL: <https://trac.cakephp.org/ticket/5644>
CakePHP : The Rapid Development Framework for PHP <https://trac.cakephp.org/>
Cake is a rapid development framework for PHP which uses commonly known design
patterns like ActiveRecord, Association Data Mapping, Front Controller and MVC.
Our primary goal is to provide a structured framework that enables PHP users at
all levels to rapidly develop robust web applications, without any loss to
flexibility.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"tickets 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/tickets-cakephp?hl=en
-~----------~----~----~----~------~----~------~--~---