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

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