public static function add($tags, $blog_id) { $data = []; if (Tags::validateTags($tags)) { $tags = explode(',', $tags); } foreach ($tags as $tag) { array_push($data, ['name' => $tag, 'blog_id' => $blog_id]); } parent::getDb()->createCommand()->batchInsert(self::tableName(), ['name', 'blog_id'], $data)->execute(); }
public function validateTags($attribute, $params) { if (!Tags::validateTags($this->tags)) { $this->addError($attribute, Tags::ERROR_MSG); } }