aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/db/mysql.php
diff options
context:
space:
mode:
authorMaat <maat-pub@mageia.biz>2012-06-03 21:23:14 +0200
committerMaat <maat-pub@mageia.biz>2012-06-03 21:23:14 +0200
commita06a38ae692551dc1c0416b835ce9924b3d9f7f5 (patch)
tree1bb2c2b3d8d56668585513890afc1d641cead0b1 /phpBB/includes/db/mysql.php
parent2db884ac2e5122be1db0582b76bf7204783a0c0d (diff)
parent19a47dfbbc4265e33c14d6679b5693d80120db4b (diff)
downloadforums-a06a38ae692551dc1c0416b835ce9924b3d9f7f5.tar
forums-a06a38ae692551dc1c0416b835ce9924b3d9f7f5.tar.gz
forums-a06a38ae692551dc1c0416b835ce9924b3d9f7f5.tar.bz2
forums-a06a38ae692551dc1c0416b835ce9924b3d9f7f5.tar.xz
forums-a06a38ae692551dc1c0416b835ce9924b3d9f7f5.zip
Merging with upstream 3.0.11
Diffstat (limited to 'phpBB/includes/db/mysql.php')
-rw-r--r--phpBB/includes/db/mysql.php70
1 files changed, 70 insertions, 0 deletions
diff --git a/phpBB/includes/db/mysql.php b/phpBB/includes/db/mysql.php
index 1e24c79577..1ccb785150 100644
--- a/phpBB/includes/db/mysql.php
+++ b/phpBB/includes/db/mysql.php
@@ -319,6 +319,76 @@ class dbal_mysql extends dbal
}
/**
+ * Gets the estimated number of rows in a specified table.
+ *
+ * @param string $table_name Table name
+ *
+ * @return string Number of rows in $table_name.
+ * Prefixed with ~ if estimated (otherwise exact).
+ *
+ * @access public
+ */
+ function get_estimated_row_count($table_name)
+ {
+ $table_status = $this->get_table_status($table_name);
+
+ if (isset($table_status['Engine']))
+ {
+ if ($table_status['Engine'] === 'MyISAM')
+ {
+ return $table_status['Rows'];
+ }
+ else if ($table_status['Engine'] === 'InnoDB' && $table_status['Rows'] > 100000)
+ {
+ return '~' . $table_status['Rows'];
+ }
+ }
+
+ return parent::get_row_count($table_name);
+ }
+
+ /**
+ * Gets the exact number of rows in a specified table.
+ *
+ * @param string $table_name Table name
+ *
+ * @return string Exact number of rows in $table_name.
+ *
+ * @access public
+ */
+ function get_row_count($table_name)
+ {
+ $table_status = $this->get_table_status($table_name);
+
+ if (isset($table_status['Engine']) && $table_status['Engine'] === 'MyISAM')
+ {
+ return $table_status['Rows'];
+ }
+
+ return parent::get_row_count($table_name);
+ }
+
+ /**
+ * Gets some information about the specified table.
+ *
+ * @param string $table_name Table name
+ *
+ * @return array
+ *
+ * @access protected
+ */
+ function get_table_status($table_name)
+ {
+ $sql = "SHOW TABLE STATUS
+ LIKE '" . $this->sql_escape($table_name) . "'";
+ $result = $this->sql_query($sql);
+ $table_status = $this->sql_fetchrow($result);
+ $this->sql_freeresult($result);
+
+ return $table_status;
+ }
+
+ /**
* Build LIKE expression
* @access private
*/