Ejemplo n.º 1
0
 public function testShouldFetchAllPersistedObjects()
 {
     self::$phactory->getConnection()->exec("DELETE FROM tests");
     $users = array();
     for ($i = 1; $i <= 10; $i++) {
         $users[] = self::$phactory->create('test');
     }
     $query = Query::getInstance();
     $query->select(Projections::count("id"))->from("tests");
     $database = new Database(self::$phactory->getConnection());
     $result = $database->query($query)->uniqueResult();
     $this->assertThat(array_pop($result), $this->equalTo(10));
 }
Ejemplo n.º 2
0
 /**
  * Counts rows on the table with the given clauses.
  *
  * @param Array $clauses
  * @return void
  * @author Dan Cox
  */
 public function countRows(array $clauses = array())
 {
     $qb = $this->database->setEntity($this->entity)->queryBuilder();
     $qb->select('count(u)');
     $this->total = $qb->getQuery()->getSingleScalarResult();
 }