I use PHP's PDO to connect to MySQL. I have this code for connection:
$dbh = new PDO ( $db_host.$db_database, $db_user, $db_pass );
$dbh->exec ( "set names utf8" );
I have a function in another file:
function Image()
{
    include 'config/connect.php';
    #connected         
    $sql = 'Select * from settings where name="X" ';
    $stmt = $dbh->prepare($sql);
    $stmt->execute();
    $row = $stmt->fetchObject();
    $Template = $row->web_site_template;
    echo "Template"; 
}
I can use include connect.php file for that, but it's not true.
I want use one function like connection() for connect to the mysql on all other functions, like:
function Image()
{
    connection();
    $sql = 'Select * from settings where name="X" ';
    $stmt = $dbh->prepare($sql);
    $stmt->execute();
    $row = $stmt->fetchObject();
    $Template = $row->web_site_template;
    echo "Template"; 
}
 
     
    