39 return extension_loaded(
'pdo_sqlite' );
51 if ( !self::isPresent() ) {
52 throw new MWException(
"Can't check SQL syntax: SQLite not found" );
54 if ( !is_array( $files ) ) {
58 $allowedTypes = array_flip( [
65 $db = DatabaseSqlite::newStandaloneInstance(
':memory:' );
67 foreach ( $files as
$file ) {
68 $err = $db->sourceFile(
$file );
74 $tables = $db->query(
"SELECT name FROM sqlite_master WHERE type='table'", __METHOD__ );
75 foreach ( $tables as $table ) {
76 if ( strpos( $table->name,
'sqlite_' ) === 0 ) {
80 $columns = $db->query(
"PRAGMA table_info({$table->name})", __METHOD__ );
81 foreach ( $columns as $col ) {
82 if ( !isset( $allowedTypes[strtolower( $col->type )] ) ) {
85 return "Table {$table->name} has column {$col->name} with non-native type '{$col->type}'";
90 return $e->getMessage();