diff --git a/db/update0.4.sql b/db/update0.4.sql index e7f52c0d69..ae78352515 100644 --- a/db/update0.4.sql +++ b/db/update0.4.sql @@ -106,3 +106,9 @@ UPDATE zt_action SET extra = substr( ACTION , 13 ) , ACTION = 'Resolved' WHERE A --20100210 adjust the reviewedDate ALTER TABLE `zt_story` CHANGE `reviewedDate` `reviewedDate` DATE NOT NULL + +--20100220 action: convert the date from timestamp to datetime +ALTER TABLE `zt_action` ADD `datetmp` VARCHAR( 255 ) NOT NULL AFTER `date`; +UPDATE zt_action SET datetmp = FROM_UNIXTIME( date ) ; +ALTER TABLE `zt_action` DROP `date`; +ALTER TABLE `zt_action` CHANGE `datetmp` `date` DATETIME NOT NULL; diff --git a/module/action/model.php b/module/action/model.php index 4cf52bc4be..b51e020efc 100644 --- a/module/action/model.php +++ b/module/action/model.php @@ -33,7 +33,7 @@ class actionModel extends model $action->objectID = $objectID; $action->actor = $this->app->user->account; $action->action = $actionType; - $action->date = time(); + $action->date = date('Y-m-d H:i:s'); $action->comment = htmlspecialchars($comment); $action->extra = $extra; $this->dao->insert(TABLE_ACTION)->data($action)->autoCheck()->exec(); @@ -43,14 +43,7 @@ class actionModel extends model /* 返回某一个对象的所有action列表。*/ public function getList($objectType, $objectID) { - $actions = array(); - $stmt = $this->dao->select('*')->from(TABLE_ACTION)->where('objectType')->eq($objectType)->andWhere('objectID')->eq($objectID)->orderBy('id')->query(); - while($action = $stmt->fetch()) - { - $action->date = date('Y-m-d H:i:s', $action->date); - $actions[$action->id] = $action; - } - + $actions = $this->dao->select('*')->from(TABLE_ACTION)->where('objectType')->eq($objectType)->andWhere('objectID')->eq($objectID)->orderBy('id')->fetchAll('id'); $histories = $this->getHistory(array_keys($actions)); foreach($actions as $actionID => $action) { @@ -63,9 +56,7 @@ class actionModel extends model /* 获得action信息。*/ public function getById($actionID) { - $action = $this->dao->findById((int)$actionID)->from(TABLE_ACTION)->fetch(); - $action->date = date('Y-m-d H:i:s', $action->date); - return $action; + return $this->dao->findById((int)$actionID)->from(TABLE_ACTION)->fetch(); } /* 返回某一个action所对应的字段修改记录。*/ @@ -142,7 +133,7 @@ class actionModel extends model { $actionType = strtolower($action->action); $objectType = strtolower($action->objectType); - $action->date = date('H:i', $action->date); + $action->date = date('H:i', strtotime($action->date)); $action->actionLabel = isset($this->lang->action->label->$actionType) ? $this->lang->action->label->$actionType : $action->action; $action->objectLabel = isset($this->lang->action->label->$objectType) ? $this->lang->action->label->$objectType : $objectType; if(strpos($action->objectLabel, '|') !== false) diff --git a/module/convert/converter/bugfree.php b/module/convert/converter/bugfree.php index e536dafd3c..981dd38147 100644 --- a/module/convert/converter/bugfree.php +++ b/module/convert/converter/bugfree.php @@ -249,7 +249,6 @@ class bugfreeConvertModel extends convertModel /* ´¦Àíaction¡£*/ foreach($bugActions as $key => $action) { - $action->date = strtotime($action->date); $action->objectID = $zentaoBugID; if($key == 0) {