PHP MySQL connection using PDO

Let us start with the basic connection code in PDO for PHP & MySQL

function DatabaseConnect() {
global $dbo;

$details['dbhost_name'] = "localhost";

$details['database'] = "sql_tutorial";
$details['username'] = "root";
$details['password'] = "test";

$dbConnString = "mysql:host=" . $details['dbhost_name'] . "; dbname=" . $details['database'];

$dbo = new PDO($dbConnString, $details['username'], $details['password']);
}
?>

0 komentar:

Post a Comment