Blame Scripts/Php/Webenv/admin/includes/classes/db_postgresql.php

878a2b
878a2b
/**
878a2b
 * Database Access (PostgreSQL)
878a2b
 *
878a2b
 * @category   Database
878a2b
 * @package    CentOS-News
878a2b
 * @author     Alain Reguera Delgado <alain.reguera@gmail.com>
878a2b
 * @copyright  2009 - CentOS Artwork SIG.
878a2b
 * @license    GPL
878a2b
 */
878a2b
878a2b
class DB_PostgreSQL
878a2b
{
878a2b
878a2b
    var $dbconn;
878a2b
878a2b
//---- Initialize class
878a2b
878a2b
    function __construct()
878a2b
    {
878a2b
        $conn_string = 'user=' . DB_USERNAME . ' password=' . DB_PASSWORD . ' dbname=' . DB_DBNAME;
878a2b
        $this->dbconn = pg_connect($conn_string) or die("Could not connect");
878a2b
    }
878a2b
878a2b
//---- Am I connected ?
878a2b
878a2b
    function check_connection()
878a2b
    {
878a2b
        if (pg_connection_status($this->dbconn) === PGSQL_CONNECTION_OK )
878a2b
        {
878a2b
            return translate('connected'); 
878a2b
        }
878a2b
        else
878a2b
        {
878a2b
            return translate('disconnected');
878a2b
        }
878a2b
878a2b
    }
878a2b
878a2b
//---- Query
878a2b
878a2b
    function query( $sql_string )
878a2b
    {
878a2b
        $result = pg_query( $this->dbconn, $sql_string ); 
878a2b
878a2b
        return $result;
878a2b
    }
878a2b
878a2b
//---- Class Destructor 
878a2b
878a2b
    function __destruct()
878a2b
    {
878a2b
878a2b
        if (pg_connection_status($this->dbconn))
878a2b
        {
878a2b
            pg_close($this->dbconn);
878a2b
        }
878a2b
        
878a2b
    }
878a2b
878a2b
}
878a2b
878a2b
$db = new DB_PostgreSQL;
878a2b
?>