/**
     * 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'])
            );
        }
    }
    /**
     * @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;
    }