ArticleAttachment::OnAttachmentDelete PHP Method

OnAttachmentDelete() public static method

It will disassociate the file from all articles.
public static OnAttachmentDelete ( integer $p_attachmentId ) : void
$p_attachmentId integer
return void
    public static function OnAttachmentDelete($p_attachmentId)
    {
        global $g_ado_db;
        $queryStr = "DELETE FROM ArticleAttachments WHERE fk_attachment_id={$p_attachmentId}";
        $g_ado_db->Execute($queryStr);
    }

Usage Example

示例#1
0
    public function delete()
    {
        if (!$this->exists()) {
            return false;
        }
        // Deleting the from from disk path is the most common place for
        // something to go wrong, so we do that first.
        $file = $this->getStorageLocation();
        if (file_exists($file) && is_file($file)) {
            unlink($file);
        }

        // Delete all the references to this image.
        ArticleAttachment::OnAttachmentDelete($this->m_data['id']);

        // Delete the description
        Translation::deletePhrase($this->m_data['fk_description_id']);

        $tmpData = $this->m_data;

        // Delete the record in the database
        $success = parent::delete();

        $logtext = getGS('File #$1 "$2" deleted.', $tmpData['id'], $tmpData['file_name']);
        Log::Message($logtext, null, 39);
        return $success;
    } // fn delete