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


PHP Expression::chain方法代码示例

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


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

示例1: testChainForm

 public function testChainForm()
 {
     $form = Form::create()->add(Primitive::string('a'))->add(Primitive::string('b'))->add(Primitive::integer('c'))->add(Primitive::integer('d'))->add(Primitive::boolean('e'))->add(Primitive::string('f'))->import(array('a' => 'true', 'c' => 123, 'd' => 123));
     $andChain = Expression::chain()->expAnd(Expression::expOr(new FormField('a'), Expression::notNull(new FormField('b'))))->expAnd(Expression::eq(new FormField('c'), new FormField('d')))->expAnd(Expression::isFalse(new FormField('e')));
     $this->assertTrue($andChain->toBoolean($form));
     $form->importMore(array('e' => 'on'));
     $this->assertFalse($andChain->toBoolean($form));
     $orChain = Expression::chain()->expOr(Expression::eq(new FormField('a'), new FormField('b')))->expOr(Expression::expOr(new FormField('e'), Expression::gt(new FormField('c'), new FormField('d'))))->expOr(Expression::in(new FormField('f'), array('qwer', 'asdf', 'zxcv')));
     $form->import(array());
     $this->assertFalse($orChain->toBoolean($form));
     $form->import(array('e' => '1'));
     $this->assertTrue($orChain->toBoolean($form));
     $form->import(array('a' => 'asdf', 'b' => 'qwerq', 'c' => '13', 'd' => '1313', 'f' => 'iukj'));
     $this->assertFalse($orChain->toBoolean($form));
     $form->import(array('c' => '13', 'd' => '12'));
     $this->assertTrue($orChain->toBoolean($form));
     $form->import(array('f' => 'asdfwer'));
     $this->assertFalse($orChain->toBoolean($form));
     $form->import(array('f' => 'qwer'));
     $this->assertTrue($orChain->toBoolean($form));
 }
开发者ID:rero26,项目名称:onphp-framework,代码行数:21,代码来源:LogicTest.class.php

示例2: toCriteria

 /**
  * @return Criteria
  **/
 public function toCriteria()
 {
     $criteria = Criteria::create($this->dao)->setDistinct($this->distinct);
     $projections = array_merge($this->properties, $this->groupChain, $this->havingChain);
     foreach ($projections as $clause) {
         $criteria->addProjection($clause->bindAll($this->parameters)->toProjection());
     }
     if ($this->where) {
         if (count($this->where) == 1) {
             $clause = reset($this->where);
             $criteria->add($clause->bindAll($this->parameters)->toLogic());
         } else {
             $logic = Expression::chain();
             foreach ($this->where as $key => $clause) {
                 $expression = $clause->bindAll($this->parameters)->toLogic();
                 if ($this->whereLogic[$key] == BinaryExpression::EXPRESSION_AND) {
                     $logic->expAnd($expression);
                 } else {
                     $logic->expOr($expression);
                 }
             }
             $criteria->add($logic);
         }
     }
     foreach ($this->orderChain as $clause) {
         $criteria->addOrder($clause->bindAll($this->parameters)->toOrder());
     }
     if ($this->limit) {
         $criteria->setLimit($this->limit->evaluate($this->parameters));
     }
     if ($this->offset) {
         $criteria->setOffset($this->offset->evaluate($this->parameters));
     }
     return $criteria;
 }
开发者ID:onphp-framework,项目名称:onphp-framework,代码行数:38,代码来源:OqlSelectQuery.class.php


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