本文整理汇总了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));
}
示例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;
}