コード例 #1
0
    /**
     * Writes data in database (once at start and update at end of file)
     */
    protected static function writeDatas()
    {
        if (!isset(self::$datas['id']))
        {
            $query  = 'INSERT INTO %s SET %s';
            $result = XMLImportDB::query(sprintf($query, self::MONITORING_TABLE, self::implodeWithKeys(self::$datas)));

            if ($result)
            {
                self::$datas['id'] = XMLImportDB::lastSerialID(self::MONITORING_TABLE, 'id');
            }
        }
        else
        {
            $query  = 'UPDATE %s SET %s WHERE `id` = %s';
            XMLImportDB::query(
                sprintf($query, self::MONITORING_TABLE, self::implodeWithKeys(self::$datas), self::$datas['id'])
            );
        }
    }
コード例 #2
0
$contentQueries[] = "UPDATE import_status
SET
    publisher_folder_id=(@temp:=publisher_folder_id),
    publisher_folder_id = new_publisher_folder_id,
    new_publisher_folder_id = @temp";
$contentQueries[] = "ALTER TABLE import_status CHANGE new_publisher_folder_id old_publisher_folder_id INT(11)";

$contentQueries[] = "UPDATE content_has_taxonomy
SET
    taxonomy_id=(@temp:=taxonomy_id),
    taxonomy_id = new_taxonomy_id,
    taxonomy_id = @temp";
$contentQueries[] = "ALTER TABLE content_has_taxonomy CHANGE new_taxonomy_id old_mm_taxonomy_id INT(11)";


$db->query( "SET FOREIGN_KEY_CHECKS = 0" );
foreach( $queries as $q )
{
    $db->query( $q );
}
foreach( $contentQueries as $q )
{
    XMLImportDB::query( $q );
}
$db->commit();
$db->query( "SET FOREIGN_KEY_CHECKS = 1" );

$cli->output( "DONE." );

コード例 #3
0
    /**
     * @param string $type
     * @param array $fieldArray
     * @param array $conditions
     * @throws XMLImportDBException
     * @return bool
     */
    private static function updateDB( $type, $fieldArray, $conditions )
    {
        $type = self::getAdjustedType( $fieldArray, $type );

        if ( empty( $type ) || empty( $fieldArray ) )
            return false;

        $table                    = 'content';
        $sqlFields                = self::buildSQLFields( $type, $table, $fieldArray );
        $sqlFields['must_update'] = array( 'key' => 'must_update', 'value' => 1 );
        $sqlFields                = array_merge(self::getAllFieldsFromTable($table), $sqlFields);
        if( empty($sqlFields['parent_id']['value']) )
            $sqlFields['parent_id']['value'] = null;
        $sql                      = sprintf( "UPDATE $table SET %s WHERE id=%s", self::implodeWithKeys( ", ", " = ", $sqlFields ), $conditions['content_id'] ); 
        $result                   = XMLImportDB::query(  $sql  );

        if ( !$result )
            throw new XMLImportDBException( 'The content has not been successfuly updated' );

        XMLImportMonitor::log( 'The content has been successfuly updated', 'info' );

        $table     = $type;
        $sqlFields = self::buildSQLFields( $type, $table, $fieldArray );

        if ( !isset( $conditions['id'] ) )
        {
            $sqlFields['content_id'] = array('key' => 'content_id','value' => $conditions['content_id']);
            $sql                     = "INSERT INTO %s SET %s";
            $result                  = XMLImportDB::query( sprintf($sql, $table, self::implodeWithKeys( ", ", " = ", $sqlFields )) );

            if ( $result )
            {
                XMLImportMonitor::log( ucfirst( $type ) . " {$conditions['id']} successfuly created", 'info' );
                $conditions['id']       = XMLImportDB::lastSerialID( $table, 'id' );
                $conditions['language'] = $sqlFields['language']['value'];
            }
        }
        else
        {
            // merge $sqlFields with empty values for clear values which not present in xml
            $sqlFields = array_merge(self::getAllFieldsFromTable($table), $sqlFields);
            $sql       = "UPDATE %s SET %s WHERE id=%s";
            $result    = XMLImportDB::query( sprintf($sql, $table, self::implodeWithKeys( ", ", " = ", $sqlFields ), $conditions['id']) );

            if ( $result )
            {
                XMLImportMonitor::log( ucfirst( $type ) . " {$conditions['id']} successfuly updated", 'info' );
                $conditions['language'] = $sqlFields['language']['value'];
            }
        }

        if ( !$result )
            throw new XMLImportDBException( ucfirst( $type ) . ' not successfuly updated' );

        if ( $type != 'article' )
        {
            $conditions['table_name']    = $table;
            $conditions['content_order'] = isset( $fieldArray['comp_art_order'] ) ? $fieldArray['comp_art_order']->calculatedValue : 0;
        }

        return $conditions;
    }
コード例 #4
0
function updateArticleImportStatus($importStatusId, $dryRun = false, eZCLI $cli = null, $statusMddEz = 0)
{
    $query = "UPDATE import_status SET status_mdd_ez = '%s' WHERE id = '%s'";
    $query = sprintf($query, $statusMddEz, $importStatusId);
    if ($dryRun)
    {
        $cli->warning($query);
        return;
    }
    XMLImportDB::query($query);
}
コード例 #5
0
    elseif ( !isset($ids['modelId']) )
    {
        $cli->output( "Publisher folder present in eZPublish but not in Model : {$path}" );
        $stop = true;
        unset($mapping[$path]);
    }
}

if ( $stop && !$force )
{
    $cli->output( "Some publisher folders are not align : please align or delete if not necessary" );
    eZExecution::cleanExit();
}

foreach ( $mapping as $ids )
{
    $queryContent = "UPDATE content SET temp_id=%s WHERE publisher_folder_id=%s";
    $res = XMLImportDB::query( sprintf($queryContent, $ids['ezId'], $ids['modelId']) );
    echo sprintf($queryContent, $ids['ezId'], $ids['modelId']) . "\n";
    $queryImportStatus = "UPDATE import_status SET temp_id=%s WHERE publisher_folder_id=%s";
    echo sprintf($queryImportStatus, $ids['ezId'], $ids['modelId']) . "\n";
    $res = XMLImportDB::query( sprintf($queryImportStatus, $ids['ezId'], $ids['modelId']) );
}

$queryOverwriteContent = "UPDATE content SET publisher_folder_id=temp_id";
XMLImportDB::query($queryOverwriteContent);
$queryOverwriteImportStatus = "UPDATE import_status SET publisher_folder_id=temp_id";
XMLImportDB::query($queryOverwriteImportStatus);

eZExecution::cleanExit();
コード例 #6
0
if ( $apply )
    $cli->notice('Update...');

foreach ( $mappingOldIDWithKey as $id => $key )
{
    if ( !isset($mappingKeyWithNewID[$key]) )
    {
        $cli->warning(sprintf('No corresponding between old (%s) and new ID for the key %s', $id, $key));
        continue;
    }

    $newId = $mappingKeyWithNewID[$key];
    $sql = sprintf('UPDATE content_has_taxonomy SET new_taxonomy_id = %s WHERE taxonomy_id = %s;', $newId, $id);
    if ( $apply )
    {
        XMLImportDB::query($sql);
    }
}



if ( $apply && $tmpColumnExist )
{
    $qCli = new QuestionInteractiveCli();
    $switchTable = $qCli->askQuestion('Switch actual column by the temporary column', array(
        'Y' => 'New values replace the old and old value are maintained in a new column',
        'N' => 'Do nothing : old values are maintained and the new value remain in the temporary column'
    ));

    if ( $switchTable == 'Y' )
    {