Merge "Revert "Remove old remapping hacks from Database::indexName()""
[lhc/web/wiklou.git] / includes / libs / rdbms / database / DatabaseSqlite.php
index 2281f23..2a5deb6 100644 (file)
  * @file
  * @ingroup Database
  */
+use Wikimedia\Rdbms\Blob;
+use Wikimedia\Rdbms\SQLiteField;
+use Wikimedia\Rdbms\ResultWrapper;
 
 /**
  * @ingroup Database
  */
-class DatabaseSqlite extends DatabaseBase {
+class DatabaseSqlite extends Database {
        /** @var bool Whether full text is enabled */
        private static $fulltextEnabled = null;
 
        /** @var string Directory */
        protected $dbDir;
-
        /** @var string File name for SQLite database file */
        protected $dbPath;
-
        /** @var string Transaction mode */
        protected $trxMode;
 
        /** @var int The number of rows affected as an integer */
        protected $mAffectedRows;
-
        /** @var resource */
        protected $mLastResult;
 
@@ -117,7 +117,7 @@ class DatabaseSqlite extends DatabaseBase {
                $p['schema'] = false;
                $p['tablePrefix'] = '';
 
-               return DatabaseBase::factory( 'sqlite', $p );
+               return Database::factory( 'sqlite', $p );
        }
 
        /**
@@ -145,7 +145,7 @@ class DatabaseSqlite extends DatabaseBase {
         * @param string $dbName
         *
         * @throws DBConnectionError
-        * @return PDO
+        * @return bool
         */
        function open( $server, $user, $pass, $dbName ) {
                $this->close();
@@ -156,7 +156,7 @@ class DatabaseSqlite extends DatabaseBase {
                }
                $this->openFile( $fileName );
 
-               return $this->mConn;
+               return (bool)$this->mConn;
        }
 
        /**
@@ -171,7 +171,7 @@ class DatabaseSqlite extends DatabaseBase {
 
                $this->dbPath = $fileName;
                try {
-                       if ( $this->mFlags & DBO_PERSISTENT ) {
+                       if ( $this->mFlags & self::DBO_PERSISTENT ) {
                                $this->mConn = new PDO( "sqlite:$fileName", '', '',
                                        [ PDO::ATTR_PERSISTENT => true ] );
                        } else {
@@ -199,6 +199,10 @@ class DatabaseSqlite extends DatabaseBase {
                return false;
        }
 
+       public function selectDB( $db ) {
+               return false; // doesn't make sense
+       }
+
        /**
         * @return string SQLite DB file path
         * @since 1.25
@@ -267,7 +271,7 @@ class DatabaseSqlite extends DatabaseBase {
        }
 
        /**
-        * Attaches external database to our connection, see http://sqlite.org/lang_attach.html
+        * Attaches external database to our connection, see https://sqlite.org/lang_attach.html
         * for details.
         *
         * @param string $name Database name to be used in queries like
@@ -504,15 +508,12 @@ class DatabaseSqlite extends DatabaseBase {
         * @param string $table
         * @param string $index
         * @param string $fname
-        * @return array
+        * @return array|false
         */
        function indexInfo( $table, $index, $fname = __METHOD__ ) {
                $sql = 'PRAGMA index_info(' . $this->addQuotes( $this->indexName( $index ) ) . ')';
                $res = $this->query( $sql, $fname );
-               if ( !$res ) {
-                       return null;
-               }
-               if ( $res->numRows() == 0 ) {
+               if ( !$res || $res->numRows() == 0 ) {
                        return false;
                }
                $info = [];
@@ -677,7 +678,7 @@ class DatabaseSqlite extends DatabaseBase {
        }
 
        /**
-        * @param string $sqls
+        * @param string[] $sqls
         * @param bool $all Whether to "UNION ALL" or not
         * @return string
         */