Dear Team,
When I create an external PHP file, I’m not sure how to properly use the program’s database connection. Currently, I establish the connection manually as follows:
php
CopyEdit
$conn = new PDO("mysql:host=localhost;dbname=order_management", "root", "");
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
However, when I upload the project to the server, I have to manually adjust the connection parameters based on the hosting environment.
Is there a recommended way to use the existing database connection from the main application in external files? Any guidance or assistance on this matter would be greatly appreciated.
Best regards,