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
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.