while using the following constructor
$this->pdo = new PDO ($this->source, $this->username, $this->password);
if I do not have any password then should I pass a NuLL value for creating a new instance of PDO?
while using the following constructor
$this->pdo = new PDO ($this->source, $this->username, $this->password);
if I do not have any password then should I pass a NuLL value for creating a new instance of PDO?
Have you checked the documentation?
PDO::__construct ( string $dsn [, string $username [, string $password [, array $driver_options ]]] )
The only required parameter is the DSN, username and password are optional.
If you know that your dn requires a password you might want to check that it is not null before you try creating your PDO-object. Or just use try / catch in that matter, like this example from php.net/PDO
<?php
/* Connect to an ODBC database using driver invocation */
$dsn = 'mysql:dbname=testdb;host=127.0.0.1';
$user = 'dbuser';
$password = 'dbpass';
try {
$dbh = new PDO($dsn, $user, $password);
} catch (PDOException $e) {
echo 'Connection failed: ' . $e->getMessage();
}
?>