コード例 #1
0
 public function testAssemble()
 {
     $statement = new DeleteStatement();
     $update = new DeleteClause();
     $update->setTable('tbl');
     $statement->addClause($update);
     $this->assertEquals('DELETE FROM tbl', QueryAssembler::stringify($statement));
     $where = new WhereClause();
     $where->addPredicate((new NotEqualPredicate())->setField('username'));
     $statement->addClause($where);
     $this->assertEquals('DELETE FROM tbl WHERE username IS NOT NULL', QueryAssembler::stringify($statement));
     $where->addPredicate((new LikePredicate())->setField('name')->setExpression(EndsWithExpression::create('Joh')));
     $this->assertEquals('DELETE FROM tbl ' . 'WHERE username IS NOT NULL AND name LIKE "%Joh"', QueryAssembler::stringify($statement));
 }
コード例 #2
0
 public function testAssemble()
 {
     $predicate = new NotLikePredicate();
     $predicate->setField('field');
     $this->assertEquals('field NOT LIKE NULL', QueryAssembler::stringify($predicate));
     $predicate->setExpression(CustomLikeExpression::create(1));
     $this->assertEquals('field NOT LIKE 1', QueryAssembler::stringify($predicate));
     $predicate->setExpression(CustomLikeExpression::create('1'));
     $this->assertEquals('field NOT LIKE "1"', QueryAssembler::stringify($predicate));
     $predicate->setExpression(CustomLikeExpression::create('abc'));
     $this->assertEquals('field NOT LIKE "abc"', QueryAssembler::stringify($predicate));
     $predicate->setExpression(EndsWithExpression::create('abc'));
     $this->assertEquals('field NOT LIKE "%abc"', QueryAssembler::stringify($predicate));
     $predicate->setExpression(ContainsExpression::create('abc'));
     $this->assertEquals('field NOT LIKE "%abc%"', QueryAssembler::stringify($predicate));
     $predicate->setExpression(StartsWithExpression::create('abc'));
     $this->assertEquals('field NOT LIKE "abc%"', QueryAssembler::stringify($predicate));
     $predicate->setExpression(CustomLikeExpression::create('a%bc'));
     $this->assertEquals('field NOT LIKE "a%bc"', QueryAssembler::stringify($predicate));
 }