Exemplo n.º 1
0
 public function __construct(OqlObjectQuery $oLeftQuery, OqlQuery $oRightQueryOrUnion)
 {
     $this->aQueries[] = $oLeftQuery;
     if ($oRightQueryOrUnion instanceof OqlUnionQuery) {
         foreach ($oRightQueryOrUnion->GetQueries() as $oSingleQuery) {
             $this->aQueries[] = $oSingleQuery;
         }
     } else {
         $this->aQueries[] = $oRightQueryOrUnion;
     }
 }
 public function InitFromOqlQuery(OqlQuery $oOqlQuery, $sQuery)
 {
     $oModelReflection = new ModelReflectionRuntime();
     $sClass = $oOqlQuery->GetClass($oModelReflection);
     $sClassAlias = $oOqlQuery->GetClassAlias();
     $aAliases = array($sClassAlias => $sClass);
     // Maintain an array of filters, because the flat list is in fact referring to a tree
     // And this will be an easy way to dispatch the conditions
     // $this will be referenced by the other filters, or the other way around...
     $aJoinItems = array($sClassAlias => $this);
     $aJoinSpecs = $oOqlQuery->GetJoins();
     if (is_array($aJoinSpecs)) {
         foreach ($aJoinSpecs as $oJoinSpec) {
             $sJoinClass = $oJoinSpec->GetClass();
             $sJoinClassAlias = $oJoinSpec->GetClassAlias();
             // Assumption: ext key on the left only !!!
             // normalization should take care of this
             $oLeftField = $oJoinSpec->GetLeftField();
             $sFromClass = $oLeftField->GetParent();
             $sExtKeyAttCode = $oLeftField->GetName();
             $oRightField = $oJoinSpec->GetRightField();
             $sToClass = $oRightField->GetParent();
             $aAliases[$sJoinClassAlias] = $sJoinClass;
             $aJoinItems[$sJoinClassAlias] = new DBObjectSearch($sJoinClass, $sJoinClassAlias);
             if ($sFromClass == $sJoinClassAlias) {
                 $oReceiver = $aJoinItems[$sToClass];
                 $oNewComer = $aJoinItems[$sFromClass];
                 $aAliasTranslation = array();
                 $oReceiver->AddCondition_ReferencedBy_InNameSpace($oNewComer, $sExtKeyAttCode, $oReceiver->m_aClasses, $aAliasTranslation);
             } else {
                 $sOperator = $oJoinSpec->GetOperator();
                 switch ($sOperator) {
                     case '=':
                         $iOperatorCode = TREE_OPERATOR_EQUALS;
                         break;
                     case 'BELOW':
                         $iOperatorCode = TREE_OPERATOR_BELOW;
                         break;
                     case 'BELOW_STRICT':
                         $iOperatorCode = TREE_OPERATOR_BELOW_STRICT;
                         break;
                     case 'NOT_BELOW':
                         $iOperatorCode = TREE_OPERATOR_NOT_BELOW;
                         break;
                     case 'NOT_BELOW_STRICT':
                         $iOperatorCode = TREE_OPERATOR_NOT_BELOW_STRICT;
                         break;
                     case 'ABOVE':
                         $iOperatorCode = TREE_OPERATOR_ABOVE;
                         break;
                     case 'ABOVE_STRICT':
                         $iOperatorCode = TREE_OPERATOR_ABOVE_STRICT;
                         break;
                     case 'NOT_ABOVE':
                         $iOperatorCode = TREE_OPERATOR_NOT_ABOVE;
                         break;
                     case 'NOT_ABOVE_STRICT':
                         $iOperatorCode = TREE_OPERATOR_NOT_ABOVE_STRICT;
                         break;
                 }
                 $oReceiver = $aJoinItems[$sFromClass];
                 $oNewComer = $aJoinItems[$sToClass];
                 $aAliasTranslation = array();
                 $oReceiver->AddCondition_PointingTo_InNameSpace($oNewComer, $sExtKeyAttCode, $oReceiver->m_aClasses, $aAliasTranslation, $iOperatorCode);
             }
         }
     }
     // Check and prepare the select information
     $this->m_aSelectedClasses = array();
     foreach ($oOqlQuery->GetSelectedClasses() as $oClassDetails) {
         $sClassToSelect = $oClassDetails->GetValue();
         $this->m_aSelectedClasses[$sClassToSelect] = $aAliases[$sClassToSelect];
     }
     $this->m_aClasses = $aAliases;
     $oConditionTree = $oOqlQuery->GetCondition();
     if ($oConditionTree instanceof Expression) {
         $this->m_oSearchCondition = $this->OQLExpressionToCondition($sQuery, $oConditionTree, $aAliases);
     }
 }
 /**
  * @return OqlSelectClauseTest
  **/
 private function assertCriteria(OqlQuery $query, Criteria $criteria)
 {
     $dialect = PostgresDialect::me();
     $this->assertEquals($query->toCriteria()->toDialectString($dialect), $criteria->toDialectString($dialect));
     return $this;
 }
Exemplo n.º 4
0
 public function __construct($oClass, $oClassAlias, $oCondition = null, $aJoins = null, $aSelect = null)
 {
     $this->m_aSelect = $aSelect;
     $this->m_oClass = $oClass;
     $this->m_oClassAlias = $oClassAlias;
     parent::__construct($oCondition, $aJoins);
 }
 /**
  * @return OqlSelectClauseTest
  **/
 private function assertCriteria(OqlQuery $query, Criteria $criteria)
 {
     $dialect = $this->getDbByType('PgSQL')->getDialect();
     $this->assertEquals($query->toCriteria()->toDialectString($dialect), $criteria->toDialectString($dialect));
     return $this;
 }