new method: Doctrine_Table::count(), returns the number of records in specified table
This commit is contained in:
parent
95bd6100a5
commit
3056d9daa5
@ -1,4 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
Doctrine::autoload('Doctrine_Access');
|
||||||
|
|
||||||
class Doctrine_Hydrate extends Doctrine_Access {
|
class Doctrine_Hydrate extends Doctrine_Access {
|
||||||
/**
|
/**
|
||||||
* @var array $fetchmodes an array containing all fetchmodes
|
* @var array $fetchmodes an array containing all fetchmodes
|
||||||
|
@ -14,7 +14,7 @@ require_once("Configurable.php");
|
|||||||
* @license LGPL
|
* @license LGPL
|
||||||
* @version 1.0 alpha
|
* @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
|
* @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() {
|
final public function getTableDescription() {
|
||||||
return $this->columns;
|
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
|
* @return Doctrine_Query a Doctrine_Query object
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user