1
0
mirror of synced 2025-01-29 19:41:45 +03:00

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

This commit is contained in:
doctrine 2006-07-23 21:56:21 +00:00
parent 95bd6100a5
commit 3056d9daa5
2 changed files with 12 additions and 1 deletions

View File

@ -1,4 +1,6 @@
<?php
Doctrine::autoload('Doctrine_Access');
class Doctrine_Hydrate extends Doctrine_Access {
/**
* @var array $fetchmodes an array containing all fetchmodes

View File

@ -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
*/