This commit is contained in:
@@ -2,17 +2,30 @@
|
||||
|
||||
namespace DMD\LaLigaApi\Controller;
|
||||
|
||||
use PDO;
|
||||
use PDOException;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
|
||||
class AdminController extends AbstractController
|
||||
{
|
||||
#[Route('/admin', name: 'app_admin')]
|
||||
#[Route('/admin/db-check', name: 'app_check_db', methods: ['GET'])]
|
||||
public function index(): Response
|
||||
{
|
||||
return $this->render('admin/index.html.twig', [
|
||||
'controller_name' => 'AdminController',
|
||||
]);
|
||||
$host = 'db.dyb-tech.com';
|
||||
$dbname = 'laliga';
|
||||
$username = 'mamb';
|
||||
$password = 'lakers06';
|
||||
try {
|
||||
$dbConnection = new PDO("mysql:host=$host;dbname=$dbname", $username, $password);
|
||||
$dbConnection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
return new JsonResponse("Connected successfully");
|
||||
}
|
||||
catch(PDOException $e)
|
||||
{
|
||||
return new JsonResponse("Connection failed: " . $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user