From 563a7f1114775fb1153391cee3772af15f393d9e Mon Sep 17 00:00:00 2001 From: Ori Livneh Date: Mon, 19 Oct 2015 19:10:10 -0700 Subject: [PATCH] Database::selectRowCount(): support $join_conds 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 | 2 +- includes/db/Database.php | 10 ++++++---- includes/db/IDatabase.php | 8 +++++--- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/includes/db/DBConnRef.php b/includes/db/DBConnRef.php index 4195719275..5a8fe920c1 100644 --- a/includes/db/DBConnRef.php +++ b/includes/db/DBConnRef.php @@ -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() ); } diff --git a/includes/db/Database.php b/includes/db/Database.php index 811a4a7209..1da85d7b3c 100644 --- a/includes/db/Database.php +++ b/includes/db/Database.php @@ -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 ) { diff --git a/includes/db/IDatabase.php b/includes/db/IDatabase.php index 51c4bfe5b1..ba3c1ddd56 100644 --- a/includes/db/IDatabase.php +++ b/includes/db/IDatabase.php @@ -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() ); /** -- 2.20.1