public function testCount() { //basic counting $qry = SQLQueryTest_DO::get()->dataQuery()->getFinalisedQuery(); $qry->setGroupBy('Common'); $ids = $this->allFixtureIDs('SQLQueryTest_DO'); $this->assertEquals(count($ids), $qry->count('"SQLQueryTest_DO"."ID"')); //test with `having` if (DB::getConn() instanceof MySQLDatabase) { $qry->setHaving('"Date" > 2012-02-01'); $this->assertEquals(1, $qry->count('"SQLQueryTest_DO"."ID"')); } }
public function testUnlimitedRowCount() { //basic counting $qry = SQLQueryTest_DO::get()->dataQuery()->getFinalisedQuery(); $ids = $this->allFixtureIDs('SQLQueryTest_DO'); $qry->setLimit(1); $count = $qry->unlimitedRowCount('"SQLQueryTest_DO"."ID"'); $this->assertEquals(count($ids), $count); $this->assertInternalType("int", $count); // Test without column - SQLSelect has different logic for this $count = $qry->unlimitedRowCount(); $this->assertEquals(2, $count); $this->assertInternalType("int", $count); //test with `having` if (DB::get_conn() instanceof MySQLDatabase) { $qry->setHaving('"Date" > 2012-02-01'); $count = $qry->unlimitedRowCount('"SQLQueryTest_DO"."ID"'); $this->assertEquals(1, $count); $this->assertInternalType("int", $count); } }