src/aws/ImageSelectCollectionActiveWindow.php
public function callbackChangeSortIndex($new, $old)
    {
        // get old position
        $newPos = (new Query)->select([$this->sortIndexFieldName])->from($this->refTableName)->where([$this->imageIdFieldName => $new['originalImageId']])->scalar();
        $oldPos = (new Query)->select([$this->sortIndexFieldName])->from($this->refTableName)->where([$this->imageIdFieldName => $old['originalImageId']])->scalar();
        
        // switch positions
        $changeNewPos = Yii::$app->db->createCommand()->update($this->refTableName, [$this->sortIndexFieldName => $oldPos], [
            $this->imageIdFieldName => $new['originalImageId'],
            $this->refFieldName => $this->itemId,
        ])->execute();
        
        $changeOldPos = Yii::$app->db->createCommand()->update($this->refTableName, [$this->sortIndexFieldName => $newPos], [
            $this->imageIdFieldName => $old['originalImageId'],
            $this->refFieldName => $this->itemId,
        ])->execute();
        
        return true;
    }
public function callbackChangeSortIndex($new, $old)
    {
        // get old position
        $newPos = (new Query)->select([$this->sortIndexFieldName])->from($this->refTableName)->where([$this->imageIdFieldName => $new['originalImageId']])->scalar();
        $oldPos = (new Query)->select([$this->sortIndexFieldName])->from($this->refTableName)->where([$this->imageIdFieldName => $old['originalImageId']])->scalar();
        
        // switch positions
        $changeNewPos = Yii::$app->db->createCommand()->update($this->refTableName, [$this->sortIndexFieldName => $oldPos], [
            $this->imageIdFieldName => $new['originalImageId'],
            $this->refFieldName => $this->itemId,
        ])->execute();
        
        $changeOldPos = Yii::$app->db->createCommand()->update($this->refTableName, [$this->sortIndexFieldName => $newPos], [
            $this->imageIdFieldName => $old['originalImageId'],
            $this->refFieldName => $this->itemId,
        ])->execute();
        
        return true;
    }
public function callbackChangeSortIndex ( $ new , $ old ) { // get old position $ newPos = ( new Query ) -> select ( [ $ this -> sortIndexFieldName ] ) -> from ( $ this -> refTableName ) -> where ( [ $ this -> imageIdFieldName => $ new [ 'originalImageId' ] ] ) -> scalar ( ) ; $ oldPos = ( new Query ) -> select ( [ $ this -> sortIndexFieldName ] ) -> from ( $ this -> refTableName ) -> where ( [ $ this -> imageIdFieldName => $ old [ 'originalImageId' ] ] ) -> scalar ( ) ; // switch positions $ changeNewPos = Yii :: $ app -> db -> createCommand ( ) -> update ( $ this -> refTableName , [ $ this -> sortIndexFieldName => $ oldPos ] , [ $ this -> imageIdFieldName => $ new [ 'originalImageId' ] , $ this -> refFieldName => $ this -> itemId , ] ) -> execute ( ) ; $ changeOldPos = Yii :: $ app -> db -> createCommand ( ) -> update ( $ this -> refTableName , [ $ this -> sortIndexFieldName => $ newPos ] , [ $ this -> imageIdFieldName => $ old [ 'originalImageId' ] , $ this -> refFieldName => $ this -> itemId , ] ) -> execute ( ) ; return true ; }
Switch position between two images.

@param integer $new
@param integer $old
@return boolean
Switch position between two images .