Commit 3056d9da authored by doctrine's avatar doctrine

new method: Doctrine_Table::count(), returns the number of records in specified table

parent 95bd6100
<?php
Doctrine::autoload('Doctrine_Access');
class Doctrine_Hydrate extends Doctrine_Access {
/**
* @var array $fetchmodes an array containing all fetchmodes
......
......@@ -14,7 +14,7 @@ require_once("Configurable.php");
* @license LGPL
* @version 1.0 alpha
*/
class Doctrine_Table extends Doctrine_Configurable {
class Doctrine_Table extends Doctrine_Configurable implements Countable {
/**
* @var boolean $isNewEntry whether ot not this table created a new record or not, used only internally
*/
......@@ -778,6 +778,15 @@ class Doctrine_Table extends Doctrine_Configurable {
final public function getTableDescription() {
return $this->columns;
}
/**
* count
*
* @return integer
*/
public function count() {
$a = $this->session->getDBH()->query("SELECT COUNT(1) FROM ".$this->tableName)->fetch(PDO::FETCH_NUM);
return current($a);
}
/**
* @return Doctrine_Query a Doctrine_Query object
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment