ArticleAttachment::AddFileToArticle PHP Method

AddFileToArticle() public static method

Link the given file with the given article.
public static AddFileToArticle ( integer $p_attachmentId, integer $p_articleNumber ) : void
$p_attachmentId integer
$p_articleNumber integer
return void
    public static function AddFileToArticle($p_attachmentId, $p_articleNumber)
    {
        global $g_ado_db;
        $queryStr = 'INSERT IGNORE INTO ArticleAttachments(fk_article_number, fk_attachment_id)' . ' VALUES(' . $p_articleNumber . ', ' . $p_attachmentId . ')';
        $g_ado_db->Execute($queryStr);
    }

Usage Example

示例#1
0
window.opener.location.reload();
</script>
<?php
	exit;
}

$f_language_selected = Input::Get('f_language_selected', 'int', 0);
$f_article_number = Input::Get('f_article_number', 'int', 0);
$articleObj = new Article($f_language_selected, $f_article_number);
if (!$articleObj->exists()) {
	camp_html_display_error(getGS("Article does not exist."), null, true);
	exit;
}

foreach ((array) $_POST['item'] as $attachmentId) {
    ArticleAttachment::AddFileToArticle((int) $attachmentId, $articleObj->getArticleNumber());
}
$logtext = getGS('$1 file/s attached to article', sizeof($_POST['item']));
Log::ArticleMessage($articleObj, $logtext, null, 38, TRUE);

?>
<script type="text/javascript">
try {
    parent.$.fancybox.reload = true;
    parent.$.fancybox.message = '<?php putGS('Files attached.'); ?>';
    parent.$.fancybox.close();
} catch (e) {}
</script>

<?php exit; ?>
All Usage Examples Of ArticleAttachment::AddFileToArticle