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