. * * @copyright (c) Visman * @license The MIT License (MIT) */ declare(strict_types=1); namespace ForkBB\Models\BBCodeList; use ForkBB\Models\Method; use ForkBB\Models\BBCodeList\BBCodeList; use ForkBB\Models\BBCodeList\Structure; use RuntimeException; use function \ForkBB\__; class Update extends Method { /** * Обновляет структуру bb-кода */ public function update(int $id, Structure $structure): BBCodeList { if (null !== ($error = $structure->getError())) { throw new RuntimeException('BBCode structure has error (' . __($error) . ')'); } $vars = [ ':id' => $id, ':tag' => $structure->tag, ':structure' => $structure->toString(), ]; $query = 'UPDATE ::bbcode SET bb_structure=?s:structure WHERE id=?i:id AND bb_tag=?s:tag AND bb_edit=1'; $this->c->DB->exec($query, $vars); return $this->model->reset(); } }