Mongolid\Cursor\Cursor::unserialize PHP Method

unserialize() public method

Unserializes this object. Re-creating the database connection.
public unserialize ( mixed $serialized ) : void
$serialized mixed Serialized cursor.
return void
    public function unserialize($serialized)
    {
        $attributes = unserialize($serialized);
        $conn = Ioc::make(Pool::class)->getConnection();
        $db = $conn->defaultDatabase;
        $collectionObject = $conn->getRawConnection()->{$db}->{$attributes['collection']};
        foreach ($attributes as $key => $value) {
            $this->{$key} = $value;
        }
        $this->collection = $collectionObject;
    }