Update answer to add categories
Content
Hi guys!
I'm trying to update an answer to associate new categories to it through a PHP API but with no sucess. When I run the API no changes to the list of categories are made. If I try, however, to change the category (the else statement of the code below) it works fine.
My code is like this:
$answer = RNCPHP\Answer::fetch(a_id);
if($answer->Categories){
$answer->Categories[0] = RNCPHP\ServiceCategory::fetch(cat_id);
}
else{
$answer->Categories = new RNCPHP\ServiceCategoryArray();
$answer->Categories[0] = RNCPHP\ServiceCategory::fetch(cat_id);
}
Does anyone know where I'm getting it wrong?
Thanks!!
0