-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.php
More file actions
27 lines (23 loc) · 692 Bytes
/
test.php
File metadata and controls
27 lines (23 loc) · 692 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<?php
include_once("config.php");
try {
$conn = new PDO("pgsql:host=$hostname;dbname=$db;", $username, $password);
// set the PDO error mode to exception
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
if ($conn){
// echo "Connected successfully\n";
$sql = "SELECT first_name, last_name, birthdate FROM customer";
echo "$sql\n";
foreach ($conn->query($sql) as $row) {
print $row['first_name'] . "\t";
print $row['last_name'] . "\t";
print $row['birthdate'] . "\n";
}
}
}
catch(PDOException $e)
{
echo "Connection failed: " . $e->getMessage();
echo "\n";
}
?>