Bienvenid@s, hoy veremos la estructura que debemos seguir para conectar a los siguientes drivers: mysql, sqlite, pgsql y sqlsrv. Todos ellos son compatibles con la extensión PDO (PHP Data Objects):
mysql
$driver = 'mysql'; $dbname = 'dbname'; $host = 'localhost'; $user = 'password'; $password = 'password'; $connection = new PDO("$driver:dbname=$dbname;host=$host;", $user, $password);
sqlite
$driver = 'sqlite'; $dbname = '../application/Database/test.sqlite'; $connection = new PDO("$driver:$dbname");;
pgsql
$driver = 'pgsql'; $dbname = 'dbname'; $host = 'localhost'; $port = 5432; $user = 'root'; $password = 'password'; $connection = new PDO("$driver:host=$host;port=$port;dbname=$dbname;user=$user;password=$password");
sqlsrv
$driver = 'sqlsrv'; $dbname = 'dbname'; $host = 'localhost'; $user = 'root'; $password = 'password'; $connection = new PDO("$driver:Server=$host;Database=$dbname", $user, $password);
No hay comentarios:
Publicar un comentario