コード例 #1
0
 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
0
ファイル: Connection.php プロジェクト: atk4/dsql
 /**
  * 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');
 }