private function renameConditionFields(ConditionGroup $conditionGroup, $namesMap = null, $originalSource = null, $newSource = null) {
        if (!$conditionGroup->isEmpty()) {
            if($namesMap == null) {
                $namesMap = $this->getColumnNames();
            }
            $conditions = &$conditionGroup->getConditions();
            foreach ($conditions as $key=>&$condition) {
                switch ($condition->type) {
                    case ConditionType::GROUP:
                        $this->renameConditionFields($condition->group, $namesMap, $originalSource, $newSource);
                        break;
                    case ConditionType::BASIC:
                        $newName = $this->getFieldNewName($condition->field, $namesMap, $originalSource, $newSource);
                        if($newName != null) {
                            $condition->field = $newName;
                        }
                        if ($condition->operator == ConditionOperator::EQUALS_FIELD) {
                            $newName = $this->getFieldNewName($condition->value, $namesMap, $originalSource, $newSource);
                            if($newName != null) {
                                $condition->value = $newName;
                            }
                        }
                        break;
                    case ConditionType::RAW:
                        foreach ($namesMap as $fieldName => $dbName) {
                            $condition->sql = preg_replace('/\b' . $fieldName . '(?=$|\s)/', $dbName, $condition->sql);
                            $condition->sql = preg_replace('/\b' . $originalSource.$fieldName . '(?=$|\s)/', "$newSource.$dbName", $condition->sql);
                        }
                        break;
                }
            }
        }
    }
private function renameConditionFields(ConditionGroup $conditionGroup, $namesMap = null, $originalSource = null, $newSource = null) {
        if (!$conditionGroup->isEmpty()) {
            if($namesMap == null) {
                $namesMap = $this->getColumnNames();
            }
            $conditions = &$conditionGroup->getConditions();
            foreach ($conditions as $key=>&$condition) {
                switch ($condition->type) {
                    case ConditionType::GROUP:
                        $this->renameConditionFields($condition->group, $namesMap, $originalSource, $newSource);
                        break;
                    case ConditionType::BASIC:
                        $newName = $this->getFieldNewName($condition->field, $namesMap, $originalSource, $newSource);
                        if($newName != null) {
                            $condition->field = $newName;
                        }
                        if ($condition->operator == ConditionOperator::EQUALS_FIELD) {
                            $newName = $this->getFieldNewName($condition->value, $namesMap, $originalSource, $newSource);
                            if($newName != null) {
                                $condition->value = $newName;
                            }
                        }
                        break;
                    case ConditionType::RAW:
                        foreach ($namesMap as $fieldName => $dbName) {
                            $condition->sql = preg_replace('/\b' . $fieldName . '(?=$|\s)/', $dbName, $condition->sql);
                            $condition->sql = preg_replace('/\b' . $originalSource.$fieldName . '(?=$|\s)/', "$newSource.$dbName", $condition->sql);
                        }
                        break;
                }
            }
        }
    }
private function renameConditionFields ( ConditionGroup $ conditionGroup , $ namesMap = null , $ originalSource = null , $ newSource = null ) { if ( ! $ conditionGroup -> isEmpty ( ) ) { if ( $ namesMap == null ) { $ namesMap = $ this -> getColumnNames ( ) ; } $ conditions = & $ conditionGroup -> getConditions ( ) ; foreach ( $ conditions as $ key => & $ condition ) { switch ( $ condition -> type ) { case ConditionType :: GROUP : $ this -> renameConditionFields ( $ condition -> group , $ namesMap , $ originalSource , $ newSource ) ; break ; case ConditionType :: BASIC : $ newName = $ this -> getFieldNewName ( $ condition -> field , $ namesMap , $ originalSource , $ newSource ) ; if ( $ newName != null ) { $ condition -> field = $ newName ; } if ( $ condition -> operator == ConditionOperator :: EQUALS_FIELD ) { $ newName = $ this -> getFieldNewName ( $ condition -> value , $ namesMap , $ originalSource , $ newSource ) ; if ( $ newName != null ) { $ condition -> value = $ newName ; } } break ; case ConditionType :: RAW : foreach ( $ namesMap as $ fieldName => $ dbName ) { $ condition -> sql = preg_replace ( '/\b' . $ fieldName . '(?=$|\s)/' , $ dbName , $ condition -> sql ) ; $ condition -> sql = preg_replace ( '/\b' . $ originalSource . $ fieldName . '(?=$|\s)/' , "$newSource.$dbName" , $ condition -> sql ) ; } break ; } } } }
Renombra los campos involucrados en condiciones where segun el mapa indicado
@param ConditionGroup $conditionGroup
@param $namesMap
@param null $originalSource
@param null $newSource
Renombra los campos involucrados en condiciones where segun el mapa indicado