I have the connection PDO
with mysql
below:
$dsn = 'mysql:host=' . self::$hostname . '; dbname=' . self::$dbname;
$opcoes = array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES UTF8');
self::$conexao = new PDO(
$dsn,
self::$username,
self::$password,
$opcoes
);
that works perfectly.
But if I put the content of the variable $dsn
next to the string of connection as below gives error > which seems to me to be concatenation .
Does anyone please help me figure out where this error is?
$opcoes = array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES UTF8');
self::$conexao = new PDO( "mysql:
host=" . self::$hostname . ";
dbname=" . self::$dbname,
self::$username,
self::$password,
$opcoes
);