DevmatGod wrote:To be more precise, the instruction tell me to use apache's setting. Witch is already configured to connect to the database.
The database functions are part of PHP, not Apache. Joomla uses its own database classes and methods for connecting to the MySQL database server and your code can just utilise them, without any connection details embedded in the code, assuming that your extension accesses the Joomla database.
On the other hand, if you want to connect to an external database, in other words, use Joomla database classes and methods to connect to a non-Joomla database, the following tutorial has all the details:
https://docs.joomla.org/Connecting_to_a ... l_database
Your code could read the credentials from a MySQL table or an .ini file so that none of those details have to be hard coded as part of your functions. Even better, if you are writing a Joomla component, add the database details into the extension as component parameters, to be filled in from Options by the Super User after the component has been installed.