php connect to postgresql

Solutions on MaxInterview for php connect to postgresql by the best coders in the world

showing results for - "php connect to postgresql"
Naelle
30 Mar 2019
1<?php
2    $db_connection = pg_connect("host=localhost dbname=dbname user=username password=password");
3	$result = pg_query($db_connection, "SELECT lastname FROM employees");
4?>
5<?php  // with PDO
6    $myPDO = new PDO('pgsql:host=localhost;dbname=dbname', 'username', 'password');
7	$result = $myPDO->query("SELECT lastname FROM employees");
8?>