public function dump()
    {
        if ( $this->printVersion() )
        {
            return 0;
        }

        if ( !$this->parseConnectionInformation() )
        {
            return 1;
        }

        $db = new phpillowCustomConnection(
            $this->connectionInfo['host'],
            $this->connectionInfo['port'],
            $this->connectionInfo['user'],
            $this->connectionInfo['pass']
        );

        $writer = new phpillowToolMultipartWriter( $this->stdout );

        // Fetch and dump documents in chunks of 1000 documents, since the
        // memory consumption might be too high otherwise
        // @TODO: Make chunk-size configurable.
        $offset = null;
        $limit  = 1000;
        do {
            $docs = $db->get( $this->connectionInfo['path'] . '/_all_docs?limit=' . $limit .
                ( $offset !== null ? '&startkey="' . $offset . '"' : '' )
            );

            foreach ( $docs->rows as $nr => $doc )
            {
                if ( ( $nr === 0 ) &&
                     ( $offset !== null ) )
                {
                    // The document which equals the startkey and already has
                    // been dumped.
                    continue;
                }

                $offset = $doc['id'];

                $this->out( "Dumping document " . $doc['id'] . "\n" );
                $doc = $db->get( $this->connectionInfo['path'] . '/' . urlencode( $doc['id'] ) );

                // Skip deleted documents
                // @TODO: Make this configurable
                if ( isset( $doc->deleted ) &&
                     ( $doc->deleted === true ) )
                {
                    continue;
                }

                // Fetch attachments explicitly. Including the attachments in
                // the doc sometimes causes errors on CouchDB 0.10
                $doc = $doc->getFullDocument();
                if ( isset( $doc['_attachments'] ) )
                {
                    foreach ( $doc['_attachments'] as $name => $attachment )
                    {
                        $data = $db->get( $this->connectionInfo['path'] . '/' . urlencode( $doc['_id'] ) . '/' . $name, null, true );
                        $doc['_attachments'][$name]['data'] = $data->data;
                    }
                }

                $writer->writeDocument( $doc );
            }
        } while ( count( $docs->rows ) > 1 );

        unset( $writer );
        return 0;
    }
public function dump()
    {
        if ( $this->printVersion() )
        {
            return 0;
        }

        if ( !$this->parseConnectionInformation() )
        {
            return 1;
        }

        $db = new phpillowCustomConnection(
            $this->connectionInfo['host'],
            $this->connectionInfo['port'],
            $this->connectionInfo['user'],
            $this->connectionInfo['pass']
        );

        $writer = new phpillowToolMultipartWriter( $this->stdout );

        // Fetch and dump documents in chunks of 1000 documents, since the
        // memory consumption might be too high otherwise
        // @TODO: Make chunk-size configurable.
        $offset = null;
        $limit  = 1000;
        do {
            $docs = $db->get( $this->connectionInfo['path'] . '/_all_docs?limit=' . $limit .
                ( $offset !== null ? '&startkey="' . $offset . '"' : '' )
            );

            foreach ( $docs->rows as $nr => $doc )
            {
                if ( ( $nr === 0 ) &&
                     ( $offset !== null ) )
                {
                    // The document which equals the startkey and already has
                    // been dumped.
                    continue;
                }

                $offset = $doc['id'];

                $this->out( "Dumping document " . $doc['id'] . "\n" );
                $doc = $db->get( $this->connectionInfo['path'] . '/' . urlencode( $doc['id'] ) );

                // Skip deleted documents
                // @TODO: Make this configurable
                if ( isset( $doc->deleted ) &&
                     ( $doc->deleted === true ) )
                {
                    continue;
                }

                // Fetch attachments explicitly. Including the attachments in
                // the doc sometimes causes errors on CouchDB 0.10
                $doc = $doc->getFullDocument();
                if ( isset( $doc['_attachments'] ) )
                {
                    foreach ( $doc['_attachments'] as $name => $attachment )
                    {
                        $data = $db->get( $this->connectionInfo['path'] . '/' . urlencode( $doc['_id'] ) . '/' . $name, null, true );
                        $doc['_attachments'][$name]['data'] = $data->data;
                    }
                }

                $writer->writeDocument( $doc );
            }
        } while ( count( $docs->rows ) > 1 );

        unset( $writer );
        return 0;
    }
public function dump ( ) { if ( $ this -> printVersion ( ) ) { return 0 ; } if ( ! $ this -> parseConnectionInformation ( ) ) { return 1 ; } $ db = new phpillowCustomConnection ( $ this -> connectionInfo [ 'host' ] , $ this -> connectionInfo [ 'port' ] , $ this -> connectionInfo [ 'user' ] , $ this -> connectionInfo [ 'pass' ] ) ; $ writer = new phpillowToolMultipartWriter ( $ this -> stdout ) ; // Fetch and dump documents in chunks of 1000 documents, since the // memory consumption might be too high otherwise // @TODO: Make chunk-size configurable. $ offset = null ; $ limit = 1000 ; do { $ docs = $ db -> get ( $ this -> connectionInfo [ 'path' ] . '/_all_docs?limit=' . $ limit . ( $ offset !== null ? '&startkey="' . $ offset . '"' : '' ) ) ; foreach ( $ docs -> rows as $ nr => $ doc ) { if ( ( $ nr === 0 ) && ( $ offset !== null ) ) { // The document which equals the startkey and already has // been dumped. continue ; } $ offset = $ doc [ 'id' ] ; $ this -> out ( "Dumping document " . $ doc [ 'id' ] . "\n" ) ; $ doc = $ db -> get ( $ this -> connectionInfo [ 'path' ] . '/' . urlencode ( $ doc [ 'id' ] ) ) ; // Skip deleted documents // @TODO: Make this configurable if ( isset ( $ doc -> deleted ) && ( $ doc -> deleted === true ) ) { continue ; } // Fetch attachments explicitly. Including the attachments in // the doc sometimes causes errors on CouchDB 0.10 $ doc = $ doc -> getFullDocument ( ) ; if ( isset ( $ doc [ '_attachments' ] ) ) { foreach ( $ doc [ '_attachments' ] as $ name => $ attachment ) { $ data = $ db -> get ( $ this -> connectionInfo [ 'path' ] . '/' . urlencode ( $ doc [ '_id' ] ) . '/' . $ name , null , true ) ; $ doc [ '_attachments' ] [ $ name ] [ 'data' ] = $ data -> data ; } } $ writer -> writeDocument ( $ doc ) ; } } while ( count ( $ docs -> rows ) > 1 ) ; unset ( $ writer ) ; return 0 ; }
Execute dump command

Returns a proper status code indicating successful execution of the
command.

@return int
Execute dump command