28 lines
649 B
PHP
Executable File
28 lines
649 B
PHP
Executable File
<?php
|
|
|
|
namespace App\Controllers\View;
|
|
|
|
use CodeIgniter\Controller;
|
|
use CodeIgniter\Database\Exceptions\DatabaseException;
|
|
|
|
class TestDBController extends Controller
|
|
{
|
|
public function index()
|
|
{
|
|
$db = \Config\Database::connect();
|
|
|
|
try {
|
|
$query = $db->query('SELECT 1');
|
|
$result = $query->getResult();
|
|
|
|
if ($result) {
|
|
echo "Database connection is successful.";
|
|
} else {
|
|
echo "Database connection failed.";
|
|
}
|
|
} catch (DatabaseException $e) {
|
|
echo "Database connection failed: " . $e->getMessage();
|
|
}
|
|
}
|
|
}
|