add db postgre

This commit is contained in:
Aleksandr Shelkovin 2025-02-07 22:07:38 +03:00
parent 35a6ac59fb
commit 74ff9fcc3a
2 changed files with 22 additions and 4 deletions

View File

@ -1,7 +1,9 @@
<?php
require_once __DIR__ . "/../model/MusicModule.php";
require_once __DIR__ . "/../view/View.php";
namespace App\Controller;
use App\Model\MusicModel;
use App\Veiw\View;
// require_once __DIR__ . "/../model/MusicModule.php";
// require_once __DIR__ . "/../view/View.php";
class AboutController
{
public function actionIndex()
@ -12,6 +14,6 @@ class AboutController
'box' => $result,
'body' => 'To home',
'auth' => false
], 'tpl_layout.php'));
], 'index_tpl.php'));
}
}

16
engine/test_db.php Normal file
View File

@ -0,0 +1,16 @@
<?php
try {
$host = '127.127.126.49';
$dbname = 'music';
$user = 'music';
$password = '123';
$port = 5432; // Default PostgreSQL port
$dsn = "pgsql:host=$host;port=$port;dbname=$dbname;user=$user;password=$password";
$db = new PDO($dsn);
$query = $db->query('SELECT * FROM top_chart');
var_dump($query->fetchAll(PDO::FETCH_ASSOC));
echo "Connected to PostgreSQL successfully!";
} catch (PDOException $e) {
echo "Connection failed: " . $e->getMessage();
}