当前位置: 首页>>代码示例>>PHP>>正文


PHP DBObject::save方法代码示例

本文整理汇总了PHP中DBObject::save方法的典型用法代码示例。如果您正苦于以下问题:PHP DBObject::save方法的具体用法?PHP DBObject::save怎么用?PHP DBObject::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DBObject的用法示例。


在下文中一共展示了DBObject::save方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: save

 public function save()
 {
     $success = parent::save();
     if ($success && isset($this->tempFile)) {
         $extension = $this->getExtension();
         //	save original
         $original = $this->name . "." . $extension;
         $path = $this->getPath(null, true);
         $this->logger->log("moving " . $this->tempFile["tmp_name"] . " to " . $path);
         $success = move_uploaded_file($this->tempFile["tmp_name"], $path);
         if ($success && $this->isImage()) {
             $thumbs = array(array('width' => 200, 'suffix' => 'small'), array('width' => 500, 'suffix' => 'med'));
             foreach ($thumbs as $thumb) {
                 $thumb_path = $this->getPath($thumb['suffix'], true);
                 $this->logger->log("thumbnailing " . $this->tempFile["tmp_name"] . " to " . $thumb_path);
                 $image = new Imagick($path);
                 $image->scaleImage($thumb['width'], 0);
                 $image->writeImage($thumb_path);
                 $image->destroy();
             }
         } else {
             if (!$success) {
                 $this->errorMessage = "Oops! We had trouble moving the file. Please try again later.";
                 $success = false;
             }
         }
     } else {
         $this->status = "Sorry, there was an error with the file: " . $this->tempFile["error"];
         $success = false;
     }
     return $success;
 }
开发者ID:npedrini,项目名称:artefacts,代码行数:32,代码来源:media.class.php

示例2: save

 function save()
 {
     if (empty($this->Creator)) {
         $this->Creator = $_SESSION['User'];
     }
     return parent::save();
 }
开发者ID:acdha,项目名称:impphp,代码行数:7,代码来源:DocumentVersion.php

示例3: save

 /**
  * Save record to the database.
  *
  * @return integer Id of the record.
  */
 public function save()
 {
     if ($this->isNewRecord()) {
         // new record
         $this->changeCreateTime();
     } else {
         $this->changeUpdateTime();
     }
     return parent::save();
 }
开发者ID:pomed,项目名称:Framework,代码行数:15,代码来源:DBTimedObject.php

示例4: save

 public function save($validate = true)
 {
     $this->logger->clear();
     //	validation
     $valid = !$validate || $this->validate();
     //	get a user_id, either by adding new user or fetching id of existing
     if ($valid) {
         $user = new User(null, $this->db);
         $user->email = $this->email;
         $user->name = $this->username;
         if (!is_null($user->email) && !empty($user->email)) {
             $user->loadFromEmail();
         } else {
             if (!is_null($user->name) && !empty($user->name)) {
                 $user->loadFromName();
             }
         }
         if ($this->isImport) {
             $user->implied = 1;
         }
         if ($user->id) {
             $this->logger->log("user found...");
         } else {
             $user->ip = $_SERVER['REMOTE_ADDR'];
         }
         $success = $user->save();
         $this->user_id = $user->id;
         if (is_null($this->user_id)) {
             $valid = false;
         }
     }
     if ($valid && isset($this->imageUpload) && !empty($this->imageUpload["name"]) && $this->imageUpload["error"] == 0) {
         $this->logger->log("saving image...");
         $image = new Media(null, $this->db);
         $image->name = time();
         $image->mime_type = $this->imageUpload['type'];
         $image->tempFile = $this->imageUpload;
         if ($image->validate()) {
             if ($image->save()) {
                 $this->logger->log("image saved...");
             } else {
                 $this->status = $image->errorMessage;
                 $valid = false;
                 $this->logger->log("error saving image...");
             }
         } else {
             $this->status = $image->errorMessage;
             $valid = false;
         }
     }
     if ($valid && isset($this->audioUpload) && !empty($this->audioUpload["name"]) && $this->audioUpload["error"] == 0) {
         $this->logger->log("saving audio...");
         $audio = new Media(null, $this->db);
         $audio->name = time();
         $audio->mime_type = $this->audioUpload['type'];
         $audio->tempFile = $this->audioUpload;
         if ($audio->validate()) {
             if ($audio->save()) {
                 $this->logger->log("audio saved...");
             } else {
                 $this->status = $audio->errorMessage;
                 $valid = false;
                 $this->logger->log("error saving audio...");
             }
         } else {
             $this->status = $audio->errorMessage;
             $valid = false;
             $this->logger->log("error validating audio...");
         }
     }
     $get_location = curl_init();
     curl_setopt($get_location, CURLOPT_URL, "http://freegeoip.net/json/" . $_SERVER['REMOTE_ADDR']);
     curl_setopt($get_location, CURLOPT_RETURNTRANSFER, 1);
     $location = curl_exec($get_location);
     $location = json_decode($location);
     //	import dream
     if ($valid) {
         $date = DateTime::createFromFormat($this->dateFormat, $this->date, new DateTimeZone($this->timezone));
         $this->occur_date = $date->format('Y-m-d');
         if ($location) {
             $this->city = $location->city;
             $this->country = $location->country_name;
             $this->latitude = $location->latitude;
             $this->longitude = $location->longitude;
         } else {
             $this->latitude = "0";
             $this->longitude = "0";
         }
         $success = parent::save();
         if ($success) {
             $this->status = "Dream added!";
         } else {
             if (isset($this->errorMessage)) {
                 $this->status = $this->errorMessage;
             } else {
                 $this->status = "Error updating dream";
             }
             $valid = false;
         }
     }
//.........这里部分代码省略.........
开发者ID:npedrini,项目名称:artefacts,代码行数:101,代码来源:dream.class.php

示例5: save

 public function save()
 {
     $rtn = parent::save();
     // create extra relationship for wechat_account_user if not existed
     if ($rtn) {
         $user = MySiteUser::getCurrentUser();
         $wechat_account_user = WechatAccountUser::findbyCombo($this->getAccountId(), $user->getId());
         if (!$wechat_account_user) {
             $wechat_account_user = new WechatAccountUser();
             $wechat_account_user->setAccountId($this->getAccountId());
             $wechat_account_user->setUserId($user->getId());
             $wechat_account_user->save();
         }
     }
     return $rtn;
 }
开发者ID:jeffreycai,项目名称:reader,代码行数:16,代码来源:UserWechatAccount.class.php


注:本文中的DBObject::save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。