database->query( 'SELECT * FROM board_columns WHERE board_id = :board_id ORDER BY position ASC', ['board_id' => $boardId] ); return array_map(fn(array $r) => BoardColumn::fromRow($r), $rows); } public function maxPosition(int $boardId): int { $row = $this->database->first( 'SELECT MAX(position) AS max_pos FROM board_columns WHERE board_id = :board_id', ['board_id' => $boardId] ); return (int) ($row['max_pos'] ?? -1); } public function insert(BoardColumn $col): BoardColumn { $this->database->execute( 'INSERT INTO board_columns (board_id, name, position, created_at, created_by, updated_at, updated_by) VALUES (:board_id, :name, :position, :created_at, :created_by, :updated_at, :updated_by)', [ 'board_id' => $col->boardId, 'name' => $col->name, 'position' => $col->position, 'created_at' => $col->createdAt, 'created_by' => $col->createdBy, 'updated_at' => $col->updatedAt, 'updated_by' => $col->updatedBy, ] ); $row = $this->database->first('SELECT last_insert_rowid() AS id'); $col->id = (int) ($row['id'] ?? 0); return $col; } public function update(BoardColumn $col): void { $this->database->execute( 'UPDATE board_columns SET name = :name, updated_at = :updated_at, updated_by = :updated_by WHERE id = :id', ['name' => $col->name, 'updated_at' => $col->updatedAt, 'updated_by' => $col->updatedBy, 'id' => $col->id] ); } public function updatePosition(int $id, int $position, string $updatedAt, string $updatedBy): void { $this->database->execute( 'UPDATE board_columns SET position = :position, updated_at = :updated_at, updated_by = :updated_by WHERE id = :id', ['position' => $position, 'updated_at' => $updatedAt, 'updated_by' => $updatedBy, 'id' => $id] ); } public function deleteByBoardId(int $boardId): void { $this->database->execute('DELETE FROM board_columns WHERE board_id = :board_id', ['board_id' => $boardId]); } }