From: Aaron Schulz Date: Tue, 20 Sep 2016 17:30:00 +0000 (-0700) Subject: Improve tableExists() for MySQL X-Git-Tag: 1.31.0-rc.0~5457^2 X-Git-Url: https://git.cyclocoop.org/%28%28?a=commitdiff_plain;h=4e4b9997493ceabd48455a5a23549f854001c9de;p=lhc%2Fweb%2Fwiklou.git Improve tableExists() for MySQL Use SHOW TABLES to avoid log spam when the table does not exist. This should make the CLI jenkins log a bit more readable. Change-Id: I027a9d0af0e42959e9f03cebb295218068a263d3 --- diff --git a/includes/libs/rdbms/database/DatabaseMysqlBase.php b/includes/libs/rdbms/database/DatabaseMysqlBase.php index 2d19081f88..9be3edee5d 100644 --- a/includes/libs/rdbms/database/DatabaseMysqlBase.php +++ b/includes/libs/rdbms/database/DatabaseMysqlBase.php @@ -518,6 +518,12 @@ abstract class DatabaseMysqlBase extends DatabaseBase { return (int)$rows; } + function tableExists( $table, $fname = __METHOD__ ) { + $encLike = $this->buildLike( $table ); + + return $this->query( "SHOW TABLES $encLike", $fname )->numRows() > 0; + } + /** * @param string $table * @param string $field