From: Ori Livneh Date: Tue, 20 Oct 2015 02:10:10 +0000 (-0700) Subject: Database::selectRowCount(): support $join_conds X-Git-Tag: 1.31.0-rc.0~9339^2 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/comptes/ajouter.php?a=commitdiff_plain;h=563a7f1114775fb1153391cee3772af15f393d9e;p=lhc%2Fweb%2Fwiklou.git 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 --- 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() ); /**