芝麻web文件管理V1.00
编辑当前文件:/home/mgatv524/www/midiatech/lib/Entity/SavedReport.php
setCommonDependencies($store, $log); $this->config = $config; $this->mediaFactory = $mediaFactory; $this->savedReportFactory = $savedReportFactory; } /** * Add */ private function add() { $this->savedReportId = $this->getStore()->insert(' INSERT INTO `saved_report` (`saveAs`, `reportScheduleId`, `mediaId`, `generatedOn`, `userId`) VALUES (:saveAs, :reportScheduleId, :mediaId, :generatedOn, :userId) ', [ 'saveAs' => $this->saveAs, 'reportScheduleId' => $this->reportScheduleId, 'mediaId' => $this->mediaId, 'generatedOn' => $this->generatedOn, 'userId' => $this->userId ]); } /** * Edit */ private function edit() { $sql = ' UPDATE `saved_report` SET `saveAs` = :saveAs, `reportScheduleId` = :reportScheduleId, `mediaId` = :mediaId, `generatedOn` = :generatedOn, `userId` = :userId WHERE savedReportId = :savedReportId '; $params = [ 'saveAs' => $this->saveAs, 'reportScheduleId' => $this->reportScheduleId, 'mediaId' => $this->mediaId, 'generatedOn' => $this->generatedOn, 'userId' => $this->userId, 'savedReportId' => $this->savedReportId, ]; $this->getStore()->update($sql, $params); } /** * Delete * @throws XiboException */ public function delete() { $this->load(); $this->getLog()->debug('Delete saved report: '.$this->saveAs.'. Generated on: '.$this->generatedOn); $this->getStore()->update('DELETE FROM `saved_report` WHERE `savedReportId` = :savedReportId', [ 'savedReportId' => $this->savedReportId ]); // Update last saved report in report schedule $this->getLog()->debug('Update last saved report in report schedule'); $this->getStore()->update(' UPDATE `reportschedule` SET lastSavedReportId = ( SELECT MAX(`savedReportId`) FROM `saved_report` WHERE `reportScheduleId`= :reportScheduleId) WHERE `reportScheduleId` = :reportScheduleId', [ 'reportScheduleId' => $this->reportScheduleId ]); } /** * Load */ public function load() { if ($this->loaded || $this->savedReportId == null) return; $this->loaded = true; } /** * Get Id * @return int */ public function getId() { return $this->savedReportId; } /** * Get Owner Id * @return int */ public function getOwnerId() { return $this->userId; } /** * Save * @param array $options */ public function save() { if ($this->savedReportId == null || $this->savedReportId == 0) $this->add(); else $this->edit(); } }