Search
 
SCRIPT & CODE EXAMPLE
 

PHP

php pdo postegresql connection

<?php

require_once 'config.php';

try {
	$dsn = "pgsql:host=$host;port=5432;dbname=$db;";
	// make a database connection
	$pdo = new PDO($dsn, $user, $password, [PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION]);

	if ($pdo) {
		echo "Connected to the $db database successfully!";
	}
} catch (PDOException $e) {
	die($e->getMessage());
} finally {
	if ($pdo) {
		$pdo = null;
	}
}
Code language: HTML, XML (xml)
Comment

PREVIOUS NEXT
Code Example
Php :: get object tyhpe php 
Php :: laravel execute command from terminal 
Php :: laravel job delay dispatch 
Php :: custom laravel auth 
Php :: if is front end wp 
Php :: date time laravel 
Php :: how to run multiple seeder at a time in laravel 
Php :: php echo new line terminal 
Php :: what is the difference between static and dynamic websites? 
Php :: running laravel queues in shared hosting 
Php :: php keep only digitts 
Php :: contains php 
Php :: sitemap for php website 
Php :: get day from date php 
Php :: in_array 
Php :: how to convert unix timestamp to date php 
Php :: how to change php variable value in javascript 
Php :: laravel validation image or file 
Php :: phpunit assert not false 
Php :: php pdo error handling 
Php :: and php 
Php :: PHP min() and max() 
Php :: laravel destroy or delete 
Php :: how to get ip address of client in php 
Php :: php full form 
Php :: str_shuffle in php 
Php :: laravel log level 
Php :: unset php 
Php :: Catches the last error php 
Php :: php check version 
ADD CONTENT
Topic
Content
Source link
Name
9+5 =