protected function _sync($shift, $dir, $conditions, $mark = false)
    {
        $config = $this->_config;

        foreach ([$config['leftField'], $config['rightField']] as $field) {
            $query = $this->_scope($this->_table->query());
            $exp = $query->newExpr();

            $movement = clone $exp;
            $movement->add($field)->add((string)$shift)->setConjunction($dir);

            $inverse = clone $exp;
            $movement = $mark ?
                $inverse->add($movement)->setConjunction('*')->add('-1') :
                $movement;

            $where = clone $exp;
            $where->add($field)->add($conditions)->setConjunction('');

            $query->update()
                ->set($exp->eq($field, $movement))
                ->where($where);

            $query->execute()->closeCursor();
        }
    }
protected function _sync($shift, $dir, $conditions, $mark = false)
    {
        $config = $this->_config;

        foreach ([$config['leftField'], $config['rightField']] as $field) {
            $query = $this->_scope($this->_table->query());
            $exp = $query->newExpr();

            $movement = clone $exp;
            $movement->add($field)->add((string)$shift)->setConjunction($dir);

            $inverse = clone $exp;
            $movement = $mark ?
                $inverse->add($movement)->setConjunction('*')->add('-1') :
                $movement;

            $where = clone $exp;
            $where->add($field)->add($conditions)->setConjunction('');

            $query->update()
                ->set($exp->eq($field, $movement))
                ->where($where);

            $query->execute()->closeCursor();
        }
    }
protected function _sync ( $ shift , $ dir , $ conditions , $ mark = false ) { $ config = $ this -> _config ; foreach ( [ $ config [ 'leftField' ] , $ config [ 'rightField' ] ] as $ field ) { $ query = $ this -> _scope ( $ this -> _table -> query ( ) ) ; $ exp = $ query -> newExpr ( ) ; $ movement = clone $ exp ; $ movement -> add ( $ field ) -> add ( ( string ) $ shift ) -> setConjunction ( $ dir ) ; $ inverse = clone $ exp ; $ movement = $ mark ? $ inverse -> add ( $ movement ) -> setConjunction ( '*' ) -> add ( '-1' ) : $ movement ; $ where = clone $ exp ; $ where -> add ( $ field ) -> add ( $ conditions ) -> setConjunction ( '' ) ; $ query -> update ( ) -> set ( $ exp -> eq ( $ field , $ movement ) ) -> where ( $ where ) ; $ query -> execute ( ) -> closeCursor ( ) ; } }
Auxiliary function used to automatically alter the value of both the left and
right columns by a certain amount that match the passed conditions

@param int $shift the value to use for operating the left and right columns
@param string $dir The operator to use for shifting the value (+/-)
@param string $conditions a SQL snipped to be used for comparing left or right
against it.
@param bool $mark whether to mark the updated values so that they can not be
modified by future calls to this function.
@return void
Auxiliary function used to automatically alter the value of both the left and right columns by a certain amount that match the passed conditions