当前位置: 首页>>代码示例>>PHP>>正文


PHP CSQLWhere::getOperationByCode方法代码示例

本文整理汇总了PHP中CSQLWhere::getOperationByCode方法的典型用法代码示例。如果您正苦于以下问题:PHP CSQLWhere::getOperationByCode方法的具体用法?PHP CSQLWhere::getOperationByCode怎么用?PHP CSQLWhere::getOperationByCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CSQLWhere的用法示例。


在下文中一共展示了CSQLWhere::getOperationByCode方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: prepareJoinReference

 protected function prepareJoinReference($reference, $alias_this, $alias_ref, $baseDefinition, $refDefenition, $isBackReference)
 {
     $new = array();
     foreach ($reference as $k => $v) {
         if ($k === 'LOGIC') {
             $new[$k] = $v;
             continue;
         }
         if (is_numeric($k)) {
             // subfilter, recursive call
             $new[$k] = $this->prepareJoinReference($v, $alias_this, $alias_ref, $baseDefinition, $refDefenition, $isBackReference);
         } else {
             // key
             $csw_result = \CSQLWhere::makeOperation($k);
             list($field, $operation) = array_values($csw_result);
             if (strpos($field, 'this.') === 0) {
                 // parse the chain
                 $definition = str_replace(\CSQLWhere::getOperationByCode($operation) . 'this.', '', $k);
                 $absDefinition = strlen($baseDefinition) ? $baseDefinition . '.' . $definition : $definition;
                 $chain = $this->getRegisteredChain($absDefinition, true);
                 if (!$isBackReference) {
                     // make sure these fields will be joined bebore the main join
                     $this->buildJoinMap(array($chain));
                 } else {
                     $chain->getLastElement()->setParameter('talias', $alias_this);
                 }
                 // recursively collect all "build_from" fields
                 if ($chain->getLastElement()->getValue() instanceof ExpressionField) {
                     $this->collectExprChains($chain);
                     $this->buildJoinMap($chain->getLastElement()->getValue()->getBuildFromChains());
                 }
                 $k = \CSQLWhere::getOperationByCode($operation) . $chain->getSqlDefinition();
             } elseif (strpos($field, 'ref.') === 0) {
                 $definition = str_replace(\CSQLWhere::getOperationByCode($operation) . 'ref.', '', $k);
                 $absDefinition = strlen($refDefenition) ? $refDefenition . '.' . $definition : $definition;
                 $chain = $this->getRegisteredChain($absDefinition, true);
                 if ($isBackReference) {
                     // make sure these fields will be joined bebore the main join
                     $this->buildJoinMap(array($chain));
                 } else {
                     $chain->getLastElement()->setParameter('talias', $alias_ref);
                 }
                 // recursively collect all "build_from" fields
                 if ($chain->getLastElement()->getValue() instanceof ExpressionField) {
                     $this->collectExprChains($chain);
                     $this->buildJoinMap($chain->getLastElement()->getValue()->getBuildFromChains());
                 }
                 $k = \CSQLWhere::getOperationByCode($operation) . $chain->getSqlDefinition();
             } else {
                 throw new Main\SystemException(sprintf('Unknown reference key `%s`', $k));
             }
             // value
             if (is_array($v)) {
                 // field = expression
                 $v = new \CSQLWhereExpression($v[0], array_slice($v, 1));
             } elseif ($v instanceof Main\DB\SqlExpression) {
                 // it's ok, nothing to do
             } elseif (!is_object($v)) {
                 if (strpos($v, 'this.') === 0) {
                     $definition = str_replace('this.', '', $v);
                     $absDefinition = strlen($baseDefinition) ? $baseDefinition . '.' . $definition : $definition;
                     $chain = $this->getRegisteredChain($absDefinition, true);
                     if (!$isBackReference) {
                         // make sure these fields will be joined bebore the main join
                         $this->buildJoinMap(array($chain));
                     } else {
                         $chain->getLastElement()->setParameter('talias', $alias_this);
                     }
                     // recursively collect all "build_from" fields
                     if ($chain->getLastElement()->getValue() instanceof ExpressionField) {
                         $this->collectExprChains($chain);
                         $this->buildJoinMap($chain->getLastElement()->getValue()->getBuildFromChains());
                     }
                     $field_def = $chain->getSqlDefinition();
                 } elseif (strpos($v, 'ref.') === 0) {
                     $definition = str_replace('ref.', '', $v);
                     $absDefinition = strlen($refDefenition) ? $refDefenition . '.' . $definition : $definition;
                     $chain = $this->getRegisteredChain($absDefinition, true);
                     if ($isBackReference) {
                         // make sure these fields will be joined bebore the main join
                         $this->buildJoinMap(array($chain));
                     } else {
                         $chain->getLastElement()->setParameter('talias', $alias_ref);
                     }
                     $this->buildJoinMap(array($chain));
                     // recursively collect all "build_from" fields
                     if ($chain->getLastElement()->getValue() instanceof ExpressionField) {
                         $this->collectExprChains($chain);
                         $this->buildJoinMap($chain->getLastElement()->getValue()->getBuildFromChains());
                     }
                     $field_def = $chain->getSqlDefinition();
                 } else {
                     throw new Main\SystemException(sprintf('Unknown reference value `%s`', $v));
                 }
                 $v = new \CSQLWhereExpression('?#', $field_def);
             } else {
                 throw new Main\SystemException(sprintf('Unknown reference value `%s`', $v));
             }
             $new[$k] = $v;
         }
//.........这里部分代码省略.........
开发者ID:ASDAFF,项目名称:entask.ru,代码行数:101,代码来源:query.php


注:本文中的CSQLWhere::getOperationByCode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。