Share on Google+Share on Google+
PDO PgSQL
Posted on: April 2, 2010 at 12:00 AM
Advertisement
In this tutorial we will study about PDO PgSQL in PHP, how to access PgSQL using PDO, etc. Examples will make this clearer.

PHP-PDO Connectivity with PostgreSQL:

We can connect with PgSQL database using conventional way pg_connect. But in this tutorial we will connect with PDO. Since it is based on object oriented method, we need to instantiate an object of the class PDO. The database connection is handled internally by PDO's constructor (__construct()).

Example:

<?php

try {

$db = new PDO("pgsql:dbname=db;host=localhost", "postgres", "1234" );

echo "PDO connection object created";

}

catch(PDOException $e)

{

echo $e->getMessage();

}

?>

Output:

PDO connection object created

 

 

Advertisement

Related Tags for PDO PgSQL:


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: April 2, 2010

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com