PHP code example of lolautruche / sqliimport

1. Go to this page and download the library: Download lolautruche/sqliimport library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

lolautruche / sqliimport example snippets


    $cli->notice( 'Creation of a new "comment" object' );
    $options = new SQLIContentOptions( array(
        'class_identifier'      => 'comment',
        'remote_id'             => 'my_ubber_cool_remote_id',
        'language'              => 'fre-FR'
    ) );
    $comment = SQLIContent::create( $options );
    $cli->notice( 'Current version : '.$comment->current_version );
    $comment->fields->subject = 'Mon super sujet';
    $comment->fields->author = 'Moi !';
    $comment->fields->message = 'Le commentaire de la mort';
    
    $comment->addTranslation( 'eng-US' );
    $comment->fields['eng-US']->subject = 'My great subject';
    $comment->fields['eng-US']->author = 'Batman';
    $comment->fields['eng-US']->message = 'Death comment';
    
    $comment->addLocation( SQLILocation::fromNodeID( 2 ) );
    $comment->addLocation( SQLILocation::fromNodeID( 43 ) );
    
    $publisher = SQLIContentPublisher::getInstance();
    $publisher->publish( $comment );

    $cli->notice( 'Current version : '.$comment->current_version );
    
    // Loop against locations
    foreach( $comment->locations as $nodeID => $location )
    {
        // Regular node attributes are available as virtual properties
        $cli->notice( $nodeID.' => '.$location->path_string.
                      ' ('.$comment->locations[$nodeID]->path_identification_string.')' );
    }
    
    // Now free memory. 
    // unset() on SQLIContent triggers eZContentObject::clearCache() 
    // and eZContentObject::resetDataMap()
    unset( $comment );
  

  // Code below is available in an import handler
  $content->fields->intro = $this->getRichContent( $myHTMLContent );
  
  // Code below is available everywhere
  $content->fields->intro = SQLIContentUtils::getRichContent( $myHTMLContent );