Пример #1
0
 /**
  * 更新记录的 created 和 updated 等字段
  *
  * @param array $row
  */
 function _setCreatedTimeFields(&$row)
 {
     $currentTime = time();
     $currentTimeStamp = $this->dbo->dbTimeStamp(time());
     foreach (array_merge($this->createdTimeFields, $this->updatedTimeFields) as $af) {
         $af = strtoupper($af);
         if (!isset($this->meta[$af])) {
             continue;
         }
         $afn = $this->meta[$af]['name'];
         if (!empty($row[$afn])) {
             continue;
         }
         switch ($this->meta[$af]['simpleType']) {
             case 'D':
                 // 日期
             // 日期
             case 'T':
                 // 日期时间
                 // 由数据库驱动获取时间格式
                 $row[$afn] = $currentTimeStamp;
                 break;
             case 'I':
                 // Unix 时间戳
                 $row[$afn] = $currentTime;
                 break;
         }
     }
 }