Can someone tell me if this code is safe?
if(!empty($tags)){
$tags = explode(',',$tags);
$tags = array_unique($tags);
foreach($tags as $tag){
if (!ctype_alnum($tag)) {
break;
}
$sql[] = '("'.$blogid.'", "'.$postid.'", "'.$tag.'")';
}
if(count($sql) > 0){
$this->db->query('INSERT INTO blogs_posts_tags (blogid, postid, tag) VALUES '.implode(",", $sql));
}
}