// DA SINISTRA VERSO DESTRA
if( (int)$tosx > (int)$fromsx ) {
if( (int)$blocks > 1 ) {
$sql = "BEGIN;
CREATE TEMPORARY TABLE moved__{$this->__tree} ( id INTEGER UNSIGNED PRIMARY KEY, oldid INTEGER UNSIGNED, sx INTEGER UNSIGNED, dx INTEGER UNSIGNED );
CREATE TEMPORARY TABLE target__{$this->__tree} ( id INTEGER UNSIGNED PRIMARY KEY, oldid INTEGER UNSIGNED, sx INTEGER UNSIGNED, dx INTEGER UNSIGNED );
INSERT INTO moved__{$this->__tree} SELECT NULL, id, sx, dx FROM {$this->__tree} WHERE sx >= {$fromsx} AND dx <= {$fromdx};
INSERT INTO target__{$this->__tree} SELECT NULL, id, sx, dx FROM {$this->__tree} WHERE sx >= {$tosx} AND dx <= {$todx};
DELETE FROM {$this->__tree} WHERE sx >= {$fromsx} AND dx <= {$fromdx};
DELETE FROM {$this->__tree} WHERE sx > {$tosx} AND dx < {$todx};
UPDATE {$this->__tree}
SET dx = ( ".( $fromdx - 1 )." ) WHERE sx = ".( $fromsx - 1 )." AND ( SELECT COUNT(id) FROM moved__{$this->__tree} ) = 1;
UPDATE {$this->__tree}
SET sx = ( sx + {$changes} ) WHERE sx > {$todx};
UPDATE {$this->__tree}
SET dx = ( dx - {$changes} ) WHERE sx >= {$fromdx} AND dx < {$tosx};
UPDATE {$this->__tree}
SET sx = ( sx - {$changes} ) WHERE sx >= {$fromdx};
UPDATE target__{$this->__tree}
SET sx = ( sx - {$changes} ), dx = ( dx - {$changes} );
UPDATE moved__{$this->__tree}
SET sx = ( id + ( SELECT MAX(sx) FROM target__{$this->__tree} ) ), dx = ( ( SELECT dx FROM {$this->__tree} WHERE id = ( SELECT oldid FROM target__{$this->__tree} WHERE id = 1 ) ) - id );
INSERT INTO {$this->__tree} ( id, sx, dx ) SELECT oldid, sx, dx FROM target__{$this->__tree} WHERE id > 1;
INSERT INTO {$this->__tree} ( id, sx, dx ) SELECT oldid, sx, dx FROM moved__{$this->__tree};
DROP TABLE moved__{$this->__tree};
DROP TABLE target__{$this->__tree};
COMMIT;";
$this->__queryRollBackable( $sql );
}
else {
$this->__skeep = true;
$this->delNode( $id_from );
$this->__skeep = true;
$this->addNode( $id_to, $id_from );
}
}