Ejemplo n.º 1
0
 function update($file_id, $editor_id, $title = false, $abstract = false, $category_id = false, $content = false)
 {
     // MeinBlog::log("update($file_id,$editor_id,$title=false,$abstract=false,$category_id=false,$content=false)");
     if (empty($file_id) || empty($editor_id)) {
         return false;
     }
     $this->pdo->beginTransaction();
     try {
         if ($content !== false) {
             $afx = MBFileContent::update($file_id, $content, $editor_id);
             if ($afx !== 1) {
                 throw new Exception("Error in modifying file content.", 1);
             }
         }
         $sql_set = " update_time=NOW(), main_editor_id = " . $this->pdo->quote($editor_id, PDO::PARAM_INT);
         if ($title !== false) {
             $sql_set .= ', title = ' . $this->pdo->quote($title);
         }
         if ($abstract !== false) {
             if ($abstract === null) {
                 $sql_set .= ', abstract = NULL ';
             } else {
                 $sql_set .= ', abstract = ' . $this->pdo->quote($abstract);
             }
         }
         if ($category_id !== false) {
             $sql_set .= ', category_id = ' . $this->pdo->quote($category_id, PDO::PARAM_INT);
         }
         $sql = "UPDATE mb_file_header SET {$sql_set} WHERE file_id=" . $this->pdo->quote($file_id, PDO::PARAM_INT);
         $afx = $this->pdo->exec($sql);
         if ($afx !== 1) {
             throw new Exception("Error in modifying file header.", 1);
         }
         $this->pdo->commit();
         return true;
     } catch (Exception $e) {
         $this->pdo->rollBack();
         MeinBlog::log($e->getMessage());
     }
     return false;
 }