Skip to content

Commit 961e822

Browse files
committed
use hasTable in testConnection() instead of raw select statement
1 parent 3ca211e commit 961e822

1 file changed

Lines changed: 7 additions & 9 deletions

File tree

userfrosting/models/database/Database.php

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,10 @@ public static function getCreatedTables(){
132132
if (!static::testConnection())
133133
return [];
134134

135-
$connection = Capsule::connection();
135+
$schema = Capsule::schema();
136+
136137
$results = [];
137-
138+
138139
$test_list = [
139140
static::getSchemaTable('user')->name,
140141
static::getSchemaTable('user_event')->name,
@@ -144,16 +145,13 @@ public static function getCreatedTables(){
144145
static::getSchemaTable('authorize_group')->name,
145146
static::$app->remember_me_table['tableName']
146147
];
147-
148+
148149
foreach ($test_list as $table){
149-
try {
150-
$stmt = $connection->select("SELECT 1 FROM $table LIMIT 1;");
151-
} catch (\PDOException $e){
152-
continue;
150+
if ($schema->hasTable($table)) {
151+
$results[] = $table;
153152
}
154-
$results[] = $table;
155153
}
156-
154+
157155
return $results;
158156
}
159157

0 commit comments

Comments
 (0)