<?php
require_once "config.php";

if ( !function_exists('get_dbconnection') ) 
{
	function get_dbconnection ()
	{
		$conn = pg_connect("options=--application_name=eoDACS_PHP host=".$GLOBALS["DB_IP"]." port=".$GLOBALS["DB_PORT"]." dbname=".$GLOBALS["DB_NAME"]." user=".$GLOBALS["DB_USER"]." password=".$GLOBALS["DB_PWD"]) or die('connection failed');
		return $conn;
	}
}

if ( !function_exists('getPDO') )
{
	function getPDO()
	{
		$db_host=$GLOBALS['DB_IP'];
		$db_name=$GLOBALS['DB_NAME'];
		$db_user=$GLOBALS['DB_USER'];
		$db_password=$GLOBALS['DB_PWD'];
		$db_port=$GLOBALS['DB_PORT'];
    	$pdo = new PDO("pgsql:host=$db_host;port=$db_port;dbname=$db_name", $db_user, $db_password);
    	$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

    	return $pdo;
    }
 }
?>
