-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-db.php
More file actions
23 lines (20 loc) · 801 Bytes
/
test-db.php
File metadata and controls
23 lines (20 loc) · 801 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<?php
try {
$pdo = DB::connection()->getPdo();
echo 'Database connection successful!' . PHP_EOL;
echo 'Database name: ' . DB::connection()->getDatabaseName() . PHP_EOL;
echo 'Driver: ' . DB::connection()->getDriverName() . PHP_EOL;
// Test if we can query the database
$tables = DB::select('SHOW TABLES');
echo 'Number of tables: ' . count($tables) . PHP_EOL;
if (count($tables) > 0) {
echo 'Sample tables: ' . PHP_EOL;
foreach (array_slice($tables, 0, 5) as $table) {
$tableName = array_values((array)$table)[0];
echo ' - ' . $tableName . PHP_EOL;
}
}
} catch (Exception $e) {
echo 'Database connection failed: ' . $e->getMessage() . PHP_EOL;
echo 'Error code: ' . $e->getCode() . PHP_EOL;
}