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

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

        // Open input stream to read contents from
        $stream = isset( $this->options['input'] ) ? fopen( $this->options['input'], 'r' ) : STDIN;
        $multipartParser = new phpillowToolMultipartParser( $stream );

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

        // Create database if it does not exist yet
        try
        {
            $db->get( $this->connectionInfo['path'] );
        }
        catch ( phpillowResponseNotFoundErrorException $e )
        {
            $db->put( $this->connectionInfo['path'] );
        }

        // Import the documents
        while ( ( $document = $multipartParser->getDocument() ) !== false )
        {
            try
            {
                $this->out( "Loading document " . $document['Content-ID'] . "\n" );
                $path = $this->connectionInfo['path'] . '/' . $document['Content-ID'];
                $db->put( $path, $this->getDocumentBody( $document ) );
            }
            catch ( phpillowException $e )
            {
                fwrite( $this->stderr, $document['Content-ID'] . ': ' . $e->getMessage() . "\n" );
                if ( !isset( $this->options['ignore-errors'] ) )
                {
                    return 1;
                }
            }
        }

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

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

        // Open input stream to read contents from
        $stream = isset( $this->options['input'] ) ? fopen( $this->options['input'], 'r' ) : STDIN;
        $multipartParser = new phpillowToolMultipartParser( $stream );

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

        // Create database if it does not exist yet
        try
        {
            $db->get( $this->connectionInfo['path'] );
        }
        catch ( phpillowResponseNotFoundErrorException $e )
        {
            $db->put( $this->connectionInfo['path'] );
        }

        // Import the documents
        while ( ( $document = $multipartParser->getDocument() ) !== false )
        {
            try
            {
                $this->out( "Loading document " . $document['Content-ID'] . "\n" );
                $path = $this->connectionInfo['path'] . '/' . $document['Content-ID'];
                $db->put( $path, $this->getDocumentBody( $document ) );
            }
            catch ( phpillowException $e )
            {
                fwrite( $this->stderr, $document['Content-ID'] . ': ' . $e->getMessage() . "\n" );
                if ( !isset( $this->options['ignore-errors'] ) )
                {
                    return 1;
                }
            }
        }

        return 0;
    }
public function load ( ) { if ( $ this -> printVersion ( ) ) { return 0 ; } if ( ! $ this -> parseConnectionInformation ( ) ) { return 1 ; } // Open input stream to read contents from $ stream = isset ( $ this -> options [ 'input' ] ) ? fopen ( $ this -> options [ 'input' ] , 'r' ) : STDIN ; $ multipartParser = new phpillowToolMultipartParser ( $ stream ) ; $ db = new phpillowCustomConnection ( $ this -> connectionInfo [ 'host' ] , $ this -> connectionInfo [ 'port' ] , $ this -> connectionInfo [ 'user' ] , $ this -> connectionInfo [ 'pass' ] ) ; // Create database if it does not exist yet try { $ db -> get ( $ this -> connectionInfo [ 'path' ] ) ; } catch ( phpillowResponseNotFoundErrorException $ e ) { $ db -> put ( $ this -> connectionInfo [ 'path' ] ) ; } // Import the documents while ( ( $ document = $ multipartParser -> getDocument ( ) ) !== false ) { try { $ this -> out ( "Loading document " . $ document [ 'Content-ID' ] . "\n" ) ; $ path = $ this -> connectionInfo [ 'path' ] . '/' . $ document [ 'Content-ID' ] ; $ db -> put ( $ path , $ this -> getDocumentBody ( $ document ) ) ; } catch ( phpillowException $ e ) { fwrite ( $ this -> stderr , $ document [ 'Content-ID' ] . ': ' . $ e -> getMessage ( ) . "\n" ) ; if ( ! isset ( $ this -> options [ 'ignore-errors' ] ) ) { return 1 ; } } } return 0 ; }
Execute load command

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

@return int
Execute load command