Example #1
0
 function test_select_complex_query()
 {
     $db = $this->getConnection();
     $q = new pdoext_Query('people');
     $q->addColumn("first_name");
     $q->setLimit(10);
     $q->setOffset(10);
     $j = $q->addJoin('accounts', 'LEFT JOIN');
     $sub = $j->addCriterion(new pdoext_query_Criteria("OR"));
     $sub->addConstraint('people.account_id', 'accounts.account_id');
     $sub->addCriterion('people.account_id', 28, '>');
     $q->addCriterion('first_name', "John");
     $this->assertSqlEqual($q->toSql($db), "\nselect `first_name`\nfrom `people`\nleft join `accounts`\non `people`.`account_id` = `accounts`.`account_id` or `people`.`account_id` > '28'\nwhere `first_name` = 'John'\nlimit 10\noffset 10\n");
 }