Merge "Improve tableExists() for MySQL"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Tue, 20 Sep 2016 17:54:42 +0000 (17:54 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Tue, 20 Sep 2016 17:54:42 +0000 (17:54 +0000)
includes/libs/rdbms/database/DatabaseMysqlBase.php

index 2d19081..9be3ede 100644 (file)
@@ -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