Example #1
0
 /**
  * 创建元数据对象
  */
 public static function CreateFileDetail($file_detail, $user_id)
 {
     $sql = "insert into " . DB_PREFIX . "_files(user_id,file_type,parent_file_id,";
     $sql .= "file_create_time,file_update_time,file_name,version_id,";
     $sql .= "file_size,file_path,event_uuid,mime_type,created_at,updated_at,file_name_pinyin) values ";
     //
     // 新建对象,需要生成对应的长度信息
     //
     $file_detail->event_uuid = MiniUtil::getEventRandomString(MConst::LEN_EVENT_UUID);
     if (isset($file_detail->version_id) === false) {
         $file_detail->version_id = 0;
     }
     $sql .= "({$user_id},{$file_detail->file_type},";
     $sql .= "{$file_detail->parent_file_id},";
     $sql .= "{$file_detail->file_create_time},";
     $sql .= "{$file_detail->file_update_time},";
     $sql .= "\"{$file_detail->file_name}\",";
     $sql .= "{$file_detail->version_id},";
     $sql .= "{$file_detail->file_size},";
     $sql .= "\"{$file_detail->file_path}\",";
     $sql .= "\"{$file_detail->event_uuid}\",";
     if ($file_detail->mime_type === NULL) {
         $sql .= "NULL,";
     } else {
         $sql .= "\"{$file_detail->mime_type}\",";
     }
     $sql .= "now(),now(),'" . MiniUtil::getPinYinByName($file_detail->file_name) . "')";
     $db_manager = MDbManager::getInstance();
     $result = $db_manager->insertDb($sql);
     if ($result === false) {
         return false;
     }
     //
     // 修复sort值为id值,确保唯一
     //
     $sql = "update  " . DB_PREFIX . "_files set sort=id where sort=0";
     $db_manager->insertDb($sql);
     return $file_detail;
 }
Example #2
0
 /**
  * 把系统中的中文文件名转化为拼音
  */
 public function updateAllFileNamePinyin()
 {
     $criteria = new CDbCriteria();
     $criteria->order = "-id";
     $items = UserFile::model()->findAll($criteria);
     foreach ($items as $item) {
         if ($item->file_name_pinyin == null) {
             //把文件名转化为拼音
             $name = $item->file_name;
             $item->file_name_pinyin = MiniUtil::getPinYinByName($name);
             $item->save();
         }
     }
 }
Example #3
0
 /**
  * 存储前的时间补全, 密码加密
  * @see CActiveRecord::beforeSave()
  */
 public function beforeSave()
 {
     parent::beforeSave();
     $this->file_name_pinyin = MiniUtil::getPinYinByName($this->file_name);
     return true;
 }