$this->trxMode = isset( $p['trxMode'] ) ? strtoupper( $p['trxMode'] ) : null;
if ( $this->trxMode &&
- !in_array( $this->trxMode, array( 'DEFERRED', 'IMMEDIATE', 'EXCLUSIVE' ) )
+ !in_array( $this->trxMode, [ 'DEFERRED', 'IMMEDIATE', 'EXCLUSIVE' ] )
) {
$this->trxMode = null;
wfWarn( "Invalid SQLite transaction mode provided." );
}
- $this->lockMgr = new FSLockManager( array( 'lockDirectory' => "{$this->dbDir}/locks" ) );
+ $this->lockMgr = new FSLockManager( [ 'lockDirectory' => "{$this->dbDir}/locks" ] );
}
/**
* @return DatabaseSqlite
* @since 1.25
*/
- public static function newStandaloneInstance( $filename, array $p = array() ) {
+ public static function newStandaloneInstance( $filename, array $p = [] ) {
$p['dbFilePath'] = $filename;
$p['schema'] = false;
$p['tablePrefix'] = '';
try {
if ( $this->mFlags & DBO_PERSISTENT ) {
$this->mConn = new PDO( "sqlite:$fileName", '', '',
- array( PDO::ATTR_PERSISTENT => true ) );
+ [ PDO::ATTR_PERSISTENT => true ] );
} else {
$this->mConn = new PDO( "sqlite:$fileName", '', '' );
}
* @param string $index
* @return string
*/
- function indexName( $index ) {
+ protected function indexName( $index ) {
return $index;
}
if ( $res->numRows() == 0 ) {
return false;
}
- $info = array();
+ $info = [];
foreach ( $res as $row ) {
$info[] = $row->name;
}
*/
function indexUnique( $table, $index, $fname = __METHOD__ ) {
$row = $this->selectRow( 'sqlite_master', '*',
- array(
+ [
'type' => 'index',
'name' => $this->indexName( $index ),
- ), $fname );
+ ], $fname );
if ( !$row || !isset( $row->sql ) ) {
return null;
}
* @param array $options
* @return bool
*/
- function insert( $table, $a, $fname = __METHOD__, $options = array() ) {
+ function insert( $table, $a, $fname = __METHOD__, $options = [] ) {
if ( !count( $a ) ) {
return true;
}
}
}
- return $this->lockMgr->lock( array( $lockName ), LockManager::LOCK_EX, $timeout )->isOK();
+ return $this->lockMgr->lock( [ $lockName ], LockManager::LOCK_EX, $timeout )->isOK();
}
public function unlock( $lockName, $method ) {
- return $this->lockMgr->unlock( array( $lockName ), LockManager::LOCK_EX )->isOK();
+ return $this->lockMgr->unlock( [ $lockName ], LockManager::LOCK_EX )->isOK();
}
/**
}
public function buildGroupConcatField(
- $delim, $table, $field, $conds = '', $join_conds = array()
+ $delim, $table, $field, $conds = '', $join_conds = []
) {
$fld = "group_concat($field," . $this->addQuotes( $delim ) . ')';
- return '(' . $this->selectSQLText( $table, $fld, $conds, null, array(), $join_conds ) . ')';
+ return '(' . $this->selectSQLText( $table, $fld, $conds, null, [], $join_conds ) . ')';
}
/**
$sql .= ' ' . $indexName . ' ON ' . $newName;
$indexInfo = $this->query( 'PRAGMA INDEX_INFO(' . $this->addQuotes( $index->name ) . ')' );
- $fields = array();
+ $fields = [];
foreach ( $indexInfo as $indexInfoRow ) {
$fields[$indexInfoRow->seqno] = $indexInfoRow->name;
}
"type='table'"
);
- $endArray = array();
+ $endArray = [];
foreach ( $result as $table ) {
$vars = get_object_vars( $table );
return $endArray;
}
+
+ /**
+ * @return string
+ */
+ public function __toString() {
+ return 'SQLite ' . (string)$this->mConn->getAttribute( PDO::ATTR_SERVER_VERSION );
+ }
+
} // end DatabaseSqlite class
/**