This indexInfo() belongs to MySQL
authorMax Semenik <maxsem@users.mediawiki.org>
Tue, 23 Nov 2010 11:14:48 +0000 (11:14 +0000)
committerMax Semenik <maxsem@users.mediawiki.org>
Tue, 23 Nov 2010 11:14:48 +0000 (11:14 +0000)
includes/db/Database.php
includes/db/DatabaseMysql.php

index cf6d9df..3f50a9e 100644 (file)
@@ -148,6 +148,15 @@ interface DatabaseType {
         */
        public function fieldInfo( $table, $field );
 
+       /**
+        * Get information about an index into an object
+        * @param $table string: Table name
+        * @param $index string: Index name
+        * @param $fname string: Calling function name
+        * @return Mixed: Database-specific index description class or false if the index does not exist
+        */
+       function indexInfo( $table, $index, $fname );
+
        /**
         * Get the number of rows affected by the last write query
         * @see http://www.php.net/mysql_affected_rows
@@ -1175,35 +1184,6 @@ abstract class DatabaseBase implements DatabaseType {
                }
        }
 
-
-       /**
-        * Get information about an index into an object
-        * Returns false if the index does not exist
-        */
-       function indexInfo( $table, $index, $fname = 'DatabaseBase::indexInfo' ) {
-               # SHOW INDEX works in MySQL 3.23.58, but SHOW INDEXES does not.
-               # SHOW INDEX should work for 3.x and up:
-               # http://dev.mysql.com/doc/mysql/en/SHOW_INDEX.html
-               $table = $this->tableName( $table );
-               $index = $this->indexName( $index );
-               $sql = 'SHOW INDEX FROM ' . $table;
-               $res = $this->query( $sql, $fname );
-
-               if ( !$res ) {
-                       return null;
-               }
-
-               $result = array();
-
-               foreach ( $res as $row ) {
-                       if ( $row->Key_name == $index ) {
-                               $result[] = $row;
-                       }
-               }
-
-               return empty( $result ) ? false : $result;
-       }
-
        /**
         * Query whether a given table exists
         */
index 39e8037..8a6d352 100644 (file)
@@ -282,6 +282,34 @@ class DatabaseMysql extends DatabaseBase {
                return false;
        }
 
+       /**
+        * Get information about an index into an object
+        * Returns false if the index does not exist
+        */
+       function indexInfo( $table, $index, $fname = 'DatabaseMysql::indexInfo' ) {
+               # SHOW INDEX works in MySQL 3.23.58, but SHOW INDEXES does not.
+               # SHOW INDEX should work for 3.x and up:
+               # http://dev.mysql.com/doc/mysql/en/SHOW_INDEX.html
+               $table = $this->tableName( $table );
+               $index = $this->indexName( $index );
+               $sql = 'SHOW INDEX FROM ' . $table;
+               $res = $this->query( $sql, $fname );
+
+               if ( !$res ) {
+                       return null;
+               }
+
+               $result = array();
+
+               foreach ( $res as $row ) {
+                       if ( $row->Key_name == $index ) {
+                               $result[] = $row;
+                       }
+               }
+
+               return empty( $result ) ? false : $result;
+       }
+
        function selectDB( $db ) {
                $this->mDBname = $db;
                return mysql_select_db( $db, $this->mConn );