Documentation

Add

int
CBlogComment::Add(
 array arFields
);

The method adds new comment to a blog post. Non-static method.

Method parameters

ParameterDescription
arFields Array of the array("field"=>"value"[, ...]) type, containing values of comment fields.

Returned value

The method returns the ID of the added comment, if the adding was successful. When an error occurs, the method will return false, and exceptions will contain errors.

See Also

Examples of use

<?
$UserIP = CBlogUser::GetUserIP();
$arFields = array(
    "TITLE" => 'My first post in the blog',
    "POST_TEXT" => 'Text of my first blog post',
    "BLOG_ID" => 1,
    "POST_ID" => 2,
    "PARENT_ID" => 0, //comment is attached to the blog post
    "AUTHOR_ID" => $USER->GetID(), //add a non-anonymous comment, 
    //otherwise, AUTHOR_NAME, AUTHOR_EMAIL must be specified 
    "DATE_CREATE" => ConvertTimeStamp(false, "FULL"), 
    "AUTHOR_IP" => $UserIP[0],
    "AUTHOR_IP1" => $UserIP[1]
);

$newID = CBlogComment::Add($arFields);
if(IntVal($newID)>0)
{
    echo "New comment [".$newID."] is added.";
}
else
{
    if ($ex = $APPLICATION->GetException())
        echo $ex->GetString();
}
?>


© «Bitrix24», 2001-2024
Up