From b324475ac88a531ad3b29024e6cf8ac511da05e5 Mon Sep 17 00:00:00 2001 From: Jeroen De Dauw Date: Tue, 14 Feb 2012 22:27:07 +0000 Subject: [PATCH] move method and added warning on count function --- includes/DBDataObject.php | 13 ------------- includes/DBTable.php | 16 ++++++++++++++++ 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/includes/DBDataObject.php b/includes/DBDataObject.php index 25b653f079..3fa528516f 100644 --- a/includes/DBDataObject.php +++ b/includes/DBDataObject.php @@ -551,19 +551,6 @@ abstract class DBDataObject { $this->readDb = $db; } - /** - * Gets if the object can take a certain field. - * - * @since 1.20 - * - * @param string $name - * - * @return boolean - */ - public function canHaveField( $name ) { - return array_key_exists( $name, $this->table->getFieldTypes() ); - } - /** * Add an amount (can be negative) to the specified field (needs to be numeric). * diff --git a/includes/DBTable.php b/includes/DBTable.php index 70bbc0d6b2..7d17b546bc 100644 --- a/includes/DBTable.php +++ b/includes/DBTable.php @@ -266,6 +266,9 @@ abstract class DBTable { * Returns the amount of matching records. * Condition field names get prefixed. * + * Note that this can be expensive on large tables. + * In such cases you might want to use DatabaseBase::estimateRowCount instead. + * * @since 1.20 * * @param array $conditions @@ -600,5 +603,18 @@ abstract class DBTable { public function getFieldNames() { return array_keys( $this->getFieldTypes() ); } + + /** + * Gets if the object can take a certain field. + * + * @since 1.20 + * + * @param string $name + * + * @return boolean + */ + public function canHaveField( $name ) { + return array_key_exists( $name, $this->getFieldTypes() ); + } } -- 2.20.1