PDO PgSQL
Posted on: April 2, 2010 at 12:00 AM
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

 

 

Related Tags for PDO PgSQL:


Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.