Database::selectRowCount(): support $join_conds
authorOri Livneh <ori@wikimedia.org>
Tue, 20 Oct 2015 02:10:10 +0000 (19:10 -0700)
committerOri Livneh <ori@wikimedia.org>
Tue, 20 Oct 2015 05:07:34 +0000 (22:07 -0700)
Add a $join_conds parameter for Database::selectRowCount(), to allow the caller
to specify join conditions for the subquery that it generates.

Change-Id: I8c0a93713c121bc5b691ae65d6b6d8f8c08c9e4c

includes/db/DBConnRef.php
includes/db/Database.php
includes/db/IDatabase.php

index 4195719..5a8fe92 100644 (file)
@@ -243,7 +243,7 @@ class DBConnRef implements IDatabase {
        }
 
        public function selectRowCount(
-               $table, $vars = '*', $conds = '', $fname = __METHOD__, $options = array()
+               $tables, $vars = '*', $conds = '', $fname = __METHOD__, $options = array(), $join_conds = array()
        ) {
                return $this->__call( __FUNCTION__, func_get_args() );
        }
index 811a4a7..1da85d7 100644 (file)
@@ -1707,19 +1707,21 @@ abstract class DatabaseBase implements IDatabase {
         *
         * Takes the same arguments as DatabaseBase::select().
         *
-        * @param string $table Table name
+        * @since 1.27 Added $join_conds parameter
+        *
+        * @param array|string $tables Table names
         * @param string $vars Unused
         * @param array|string $conds Filters on the table
         * @param string $fname Function name for profiling
         * @param array $options Options for select
+        * @param array $join_conds Join conditions (since 1.27)
         * @return int Row count
-        * @since 1.24
         */
        public function selectRowCount(
-               $table, $vars = '*', $conds = '', $fname = __METHOD__, $options = array()
+               $tables, $vars = '*', $conds = '', $fname = __METHOD__, $options = array(), $join_conds = array()
        ) {
                $rows = 0;
-               $sql = $this->selectSQLText( $table, '1', $conds, $fname, $options );
+               $sql = $this->selectSQLText( $tables, '1', $conds, $fname, $options, $join_conds );
                $res = $this->query( "SELECT COUNT(*) AS rowcount FROM ($sql) tmp_count", $fname );
 
                if ( $res ) {
index 51c4bfe..ba3c1dd 100644 (file)
@@ -699,16 +699,18 @@ interface IDatabase {
         *
         * Takes the same arguments as IDatabase::select().
         *
-        * @param string $table Table name
+        * @since 1.27 Added $join_conds parameter
+        *
+        * @param array|string $tables Table names
         * @param string $vars Unused
         * @param array|string $conds Filters on the table
         * @param string $fname Function name for profiling
         * @param array $options Options for select
+        * @param array $join_conds Join conditions (since 1.27)
         * @return int Row count
-        * @since 1.24
         */
        public function selectRowCount(
-               $table, $vars = '*', $conds = '', $fname = __METHOD__, $options = array()
+               $tables, $vars = '*', $conds = '', $fname = __METHOD__, $options = array(), $join_conds = array()
        );
 
        /**