本文整理汇总了PHP中Expression::execute方法的典型用法代码示例。如果您正苦于以下问题:PHP Expression::execute方法的具体用法?PHP Expression::execute怎么用?PHP Expression::execute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Expression
的用法示例。
在下文中一共展示了Expression::execute方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testExpression
function testExpression()
{
// Expression 1
$exp = new Expression('x => x > 10');
$this->assertTrue($exp->execute(20));
$this->assertFalse($exp->execute(5));
// Expression 2 ( Lambda Expression )
$exp = new Expression(function ($x) {
return is_string($x);
});
$this->assertFalse($exp->execute(10));
$this->assertTrue($exp->execute('Hello'));
// Expression 3
$exp = new Expression('user => user->name == "Alireza" AND user->id == 12');
$this->assertTrue($exp->execute((object) ['name' => 'Alireza', 'id' => 12]));
}
示例2: execute
/**
* Execute Expression by using this connection.
*
* @param Expression $expr
*
* @return PDOStatement
*/
public function execute(Expression $expr)
{
// If custom connection is set, execute again using that
if ($this->connection && $this->connection !== $this) {
return $expr->execute($this->connection);
}
throw new Exception('Queries cannot be executed through this connection');
}