The PDO represents a connection between PHP and the Database Server.
Given the word object in the title, we know that to use PDO, we need to instantiate it first.
From the PHP manual , I got :
public PDO::__construct ( string
or you can use
$pdo = new PDO(string
The PHP manual says that DSN (Data Source Name) contains the information required to connect to a database.
In general, a DSN consists of the PDO driver name, followed by a colon, followed by the PDO driver-specific connection syntax
I use mysql , so in my case, it will be
Given the word object in the title, we know that to use PDO, we need to instantiate it first.
From the PHP manual , I got :
public PDO::__construct ( string
$dsn
[, string $username
[, string $password
[, array $options
]]] )or you can use
$pdo = new PDO(string
$dsn
[, string $username
[, string $password
[, array $options
]]) ;The PHP manual says that DSN (Data Source Name) contains the information required to connect to a database.
In general, a DSN consists of the PDO driver name, followed by a colon, followed by the PDO driver-specific connection syntax
I use mysql , so in my case, it will be
"mysql:host=$databasehost;dbname=$databasename"
The username and password are clear.
Options :A key=>value array of driver-specific connection options.
Ref :https://php.net/manual/en/ref.pdo-mysql.php
No comments:
Post a Comment