Revision #11 was created by softark on Mar 15, 2018, 2:00:39 AM.
error in sample code fixed
Content
[...]
/* clear the categories of the post before saving */
PostCategory::deleteAll(['post_id' => $this->id]);
if (is_array($this->category_ids)) {
foreach($this->category_ids as $category_id) {
$pc = new PostCategory();
$pc->post_id = $this->post_id;
$pc->category_id = $category_id;
$pc->save();
}
}
/* Be careful, $this->category_ids can be empty */