Example #1
0
 function conectar($server = IP_SERVER, $user = USER_DB, $pass = PASSWORD_DB, $based = DB, $puerto = PORT, $tipo_conexion = "N")
 {
     try {
         switch ($tipo_conexion) {
             case "N":
                 // Conexion a B.D no persistente
                 $this->id_conexion = @pg_connect("host={$server} port={$puerto} dbname={$based} user={$user} password={$pass}");
                 break;
             case "P":
                 // Conexion a B.D persistente
                 $this->id_conexion = @pg_pconnect("host={$server} port={$puerto} dbname={$based} user={$user} password={$pass}");
                 break;
             default:
                 // Otros casos
                 $this->id_conexion = @pg_connect("host={$server} port={$puerto} dbname={$based} user={$user} password={$pass}");
                 break;
         }
         if ($this->id_conexion) {
             //$this->id_conexion->set_charset(CODEC);
             return $this->id_conexion;
         } else {
             throw new Exception("Error 01: " . ($this->id_conexion ? pg_error($this->id_conexion) : 'Servidor o B.D. no disponible'));
         }
     } catch (Exception $e) {
         $this->error1 = $e->getMessage();
         return null;
     }
 }
 public function connect()
 {
     if ($this->bConnected) {
         return $this->rConnection;
     }
     $iLevel = error_reporting();
     // to suppress E_WARNING that can happen
     error_reporting(0);
     if ($this->iPersistence == 0) {
         // plain connect
         $this->rConnection = pg_connect($this->sConnString, PGSQL_CONNECT_FORCE_NEW);
     } else {
         if ($this->iPersistence == 1) {
             // persistent connect
             $this->rConnection = pg_pconnect($this->sConnString);
         } else {
             if ($this->iPersistence == PGSQL_CONNECT_FORCE_NEW) {
                 // persistent connect forced new
                 $this->rConnection = pg_connect($this->sConnString, PGSQL_CONNECT_FORCE_NEW);
             }
         }
     }
     // lets restore previous level
     error_reporting($iLevel);
     $iConnStatus = pg_connection_status($this->rConnection);
     if ($iConnStatus !== PGSQL_CONNECTION_OK) {
         if (is_resource($this->rConnection)) {
             pg_close($this->rConnection);
         }
         throw new \Exception('Unable to connect.');
     }
     $this->bConnected = true;
     return $this->rConnection;
 }
Example #3
0
 protected function _connect()
 {
     $connstr = '';
     foreach ($this->_config as $param => $value) {
         if ($value) {
             switch ($param) {
                 case 'host':
                     $connstr .= "host={$value} ";
                     break;
                 case 'database':
                     $connstr .= "dbname={$value} ";
                     break;
                 case 'port':
                     $connstr .= "port={$value} ";
                     break;
                 case 'username':
                     $connstr .= "user={$value} ";
                     break;
                 case 'password':
                     $connstr .= "password={$value} ";
                     break;
             }
         }
     }
     if (isset($this->_config['persistent'])) {
         $this->_connection = pg_pconnect($connstr);
     } else {
         $this->_connection = pg_connect($connstr);
     }
     if (pg_connection_status($this->_connection) !== PGSQL_CONNECTION_OK) {
         $this->_errorHandler(1, "Cconnection failed. ");
     }
 }
Example #4
0
 function connect()
 {
     $this->close();
     $p = $this->params;
     $connstr = "dbname={$p['name']}";
     if ($p['user']) {
         $connstr .= " user={$p['user']}";
     }
     if ($p['pass']) {
         $connstr .= " password={$p['pass']}";
     }
     if ($p['host']) {
         $connstr .= " host={$p['host']}";
     }
     if ($p['port']) {
         $connstr .= " port={$p['port']}";
     }
     if ($p['persistent']) {
         $this->conn = pg_pconnect($connstr);
     } else {
         $this->conn = pg_connect($connstr);
     }
     if (!$this->conn) {
         $this->_catch("Unable to connect to the database: " . pg_last_error());
         return false;
     }
     return true;
 }
Example #5
0
 public function open()
 {
     if (!$this->handle) {
         if (!$this->port) {
             $this->port = 5432;
         }
         $str_conn = "host={$this->server} port={$this->port} dbname={$this->source} user={$this->user} password={$this->pass}";
         if ($this->persistent) {
             $this->handle = pg_pconnect($str_conn);
         } else {
             $this->handle = pg_connect($str_conn);
         }
         if (!$this->handle) {
             $this->connection_error(pg_last_error());
             $this->handle = false;
             return false;
         }
         // Keep track of the number of connections we create
         $this->increment_counters();
     }
     // Flag Connection as Open
     $this->conn_open = true;
     // Start Transaction?
     if (!$this->auto_commit && !$this->trans_started) {
         $this->start_trans();
     }
     return true;
 }
 function connect()
 {
     global $php_errormsg;
     $persistent = isset($this->config['persistent']) ? $this->config['persistent'] : null;
     $connstr = '';
     if ($host = $this->config['host']) {
         $connstr = 'host=' . $host;
     }
     if ($port = $this->config['port']) {
         $connstr .= ' port=' . $port;
     }
     if ($database = $this->config['database']) {
         $connstr .= ' dbname=\'' . addslashes($database) . '\'';
     }
     if ($user = $this->config['user']) {
         $connstr .= ' user=\'' . addslashes($user) . '\'';
     }
     if ($password = $this->config['password']) {
         $connstr .= ' password=\'' . addslashes($password) . '\'';
     }
     if ($persistent) {
         $conn = @pg_pconnect($connstr);
     } else {
         $conn = @pg_connect($connstr);
     }
     if (!is_resource($conn)) {
         $this->_raiseError($php_errormsg);
     }
     if (isset($this->config['charset']) && ($charset = $this->config['charset'])) {
         pg_set_client_encoding($conn, $charset);
     }
     $this->connectionId = $conn;
 }
Example #7
0
 public function connect($config = [])
 {
     $this->config = $config;
     $dsn = 'host=' . $this->config['host'] . ' ';
     if (!empty($this->config['port'])) {
         $dsn .= 'port=' . $this->config['port'] . ' ';
     }
     if (!empty($this->config['database'])) {
         $dsn .= 'dbname=' . $this->config['database'] . ' ';
     }
     if (!empty($this->config['user'])) {
         $dsn .= 'user='******'user'] . ' ';
     }
     if (!empty($this->config['password'])) {
         $dsn .= 'password='******'password'] . ' ';
     }
     if (!empty($this->config['dsn'])) {
         $dsn = $this->config['dsn'];
     }
     $dsn = rtrim($dsn);
     $this->connect = $this->config['pconnect'] === true ? @pg_pconnect($dsn) : @pg_connect($dsn);
     if (empty($this->connect)) {
         die(getErrorMessage('Database', 'connectError'));
     }
     if (!empty($this->config['charset'])) {
         pg_set_client_encoding($this->connect, $this->config['charset']);
     }
 }
Example #8
0
/**
 *  db_connect() - Connect to the database
 *  Notice the global vars that must be set up
 *  Sets up a global $gfconn variable which is used 
 *  in other functions in this library.
 */
function db_connect()
{
    global $sys_dbhost, $sys_dbuser, $sys_dbpasswd, $gfconn, $sys_dbname, $sys_db_use_replication, $sys_dbport, $sys_dbreaddb, $sys_dbreadhost;
    //
    //	Connect to primary database
    //
    if (function_exists("pg_pconnect")) {
        $gfconn = pg_pconnect(pg_connectstring($sys_dbname, $sys_dbuser, $sys_dbpasswd, $sys_dbhost, $sys_dbport));
    } else {
        print "function pg_pconnect doesn't exist: no postgresql interface";
        exit;
    }
    //
    //	If any replication is configured, connect
    //
    if ($sys_db_use_replication) {
        $gfconn2 = pg_pconnect(pg_connectstring($sys_dbreaddb, $sys_dbuser, $sys_dbpasswd, $sys_dbreadhost, $sys_dbreadport));
    } else {
        $gfconn2 = $gfconn;
    }
    //
    //	Now map the physical database connections to the
    //	"virtual" list that is used to distribute load in db_query()
    //
    define('SYS_DB_PRIMARY', $gfconn);
    define('SYS_DB_STATS', $gfconn2);
    define('SYS_DB_TROVE', $gfconn2);
    define('SYS_DB_SEARCH', $gfconn2);
    // Register top-level "finally" handler to abort current
    // transaction in case of error
    register_shutdown_function("system_cleanup");
}
Example #9
0
 public function connect()
 {
     // Already connected
     if (is_resource($this->connection)) {
         return;
     }
     extract($this->config['connection']);
     $str = (isset($socket) and $socket) ? '' : (isset($host) ? "host='{$host}'" : '');
     $str .= isset($port) ? " port='{$port}'" : '';
     $str .= isset($user) ? " user='******'" : '';
     $str .= isset($pass) ? " password='******'" : '';
     $str .= isset($database) ? " dbname='{$database}'" : '';
     // Connect to the database
     $this->connection = $this->config['persistent'] === TRUE ? pg_pconnect($str, PGSQL_CONNECT_FORCE_NEW) : pg_connect($str, PGSQL_CONNECT_FORCE_NEW);
     // A descriptive E_WARNING should have been thrown upon error
     // Test the return value as a last resort
     if (!is_resource($this->connection)) {
         throw new Database_Exception('Unable to connect to database');
     }
     if (isset($this->config['character_set'])) {
         // Set the character set
         $this->set_charset($this->config['character_set']);
     }
     if (empty($this->config['schema'])) {
         // Assume the default schema without changing the search path
         $this->config['schema'] = 'public';
     } else {
         $this->schema($this->config['schema']);
     }
 }
Example #10
0
 /**
  * Connect to server
  */
 function sql_connect($sqlserver, $sqluser, $sqlpassword, $database, $port = false, $persistency = false)
 {
     $this->connect_string = '';
     if ($sqluser) {
         $this->connect_string .= "user={$sqluser} ";
     }
     if ($sqlpassword) {
         $this->connect_string .= "password={$sqlpassword} ";
     }
     if ($sqlserver) {
         if (strpos($sqlserver, ':') !== false) {
             list($sqlserver, $sqlport) = explode(':', $sqlserver);
             $this->connect_string .= "host={$sqlserver} port={$sqlport} ";
         } else {
             if ($sqlserver != "localhost") {
                 $this->connect_string .= "host={$sqlserver} ";
             }
             if ($port) {
                 $this->connect_string .= "port={$port} ";
             }
         }
     }
     if ($database) {
         $this->dbname = $database;
         $this->connect_string .= "dbname={$database}";
     }
     $this->persistency = $persistency;
     $this->db_connect_id = $this->persistency ? @pg_pconnect($this->connect_string) : @pg_connect($this->connect_string);
     return $this->db_connect_id ? $this->db_connect_id : $this->sql_error('');
 }
 public function conectar()
 {
     if (!parent::$enlace) {
         parent::$enlace = pg_pconnect('host=' . FS_HOST . ' dbname=' . FS_DB_NAME . ' port=' . FS_DB_PORT . ' user='******' password=' . FS_PASSDB);
     }
     return parent::$enlace;
 }
Example #12
0
 public function connect()
 {
     if ($this->_connection) {
         return;
     }
     try {
         $this->_connection = empty($this->_config['connection']['persistent']) ? pg_connect($this->_config['connection']['info'], PGSQL_CONNECT_FORCE_NEW) : pg_pconnect($this->_config['connection']['info'], PGSQL_CONNECT_FORCE_NEW);
     } catch (ErrorException $e) {
         throw new Database_Exception(':error', array(':error' => $e->getMessage()));
     }
     if (!is_resource($this->_connection)) {
         throw new Database_Exception('Unable to connect to PostgreSQL ":name"', array(':name' => $this->_instance));
     }
     $this->_version = pg_parameter_status($this->_connection, 'server_version');
     if (!empty($this->_config['charset'])) {
         $this->set_charset($this->_config['charset']);
     }
     if (empty($this->_config['schema'])) {
         // Assume the default schema without changing the search path
         $this->_config['schema'] = 'public';
     } else {
         if (!pg_send_query($this->_connection, 'SET search_path = ' . $this->_config['schema'] . ', pg_catalog')) {
             throw new Database_Exception(pg_last_error($this->_connection));
         }
         if (!($result = pg_get_result($this->_connection))) {
             throw new Database_Exception(pg_last_error($this->_connection));
         }
         if (pg_result_status($result) !== PGSQL_COMMAND_OK) {
             throw new Database_Exception(pg_result_error($result));
         }
     }
 }
Example #13
0
 function DBLayer($db_host, $db_username, $db_password, $db_name, $db_prefix, $p_connect)
 {
     $this->prefix = $db_prefix;
     if ($db_host) {
         if (strpos($db_host, ':') !== false) {
             list($db_host, $dbport) = explode(':', $db_host);
             $connect_str[] = 'host=' . $db_host . ' port=' . $dbport;
         } else {
             $connect_str[] = 'host=' . $db_host;
         }
     }
     if ($db_name) {
         $connect_str[] = 'dbname=' . $db_name;
     }
     if ($db_username) {
         $connect_str[] = 'user='******'password='******' ', $connect_str));
     } else {
         $this->link_id = @pg_connect(implode(' ', $connect_str));
     }
     if (!$this->link_id) {
         error('Unable to connect to PostgreSQL server.', __FILE__, __LINE__);
     }
     // Setup the client-server character set (UTF-8)
     if (!defined('FORUM_NO_SET_NAMES')) {
         $this->set_names('utf8');
     }
     return $this->link_id;
 }
Example #14
0
/**
 * The function to open a database connection, or return the resource if already open
 *
 * @param string $database   The name of the database config to use
 *                           (Must match the database section name in the conf file)
 * @return resource|false    The PgSQL database resource
 *                           or false on failure
 */
function OA_Dal_Delivery_connect($database = 'database')
{
    // If a connection already exists, then return that
    if ($database == 'database' && isset($GLOBALS['_MAX']['ADMIN_DB_LINK']) && is_resource($GLOBALS['_MAX']['ADMIN_DB_LINK'])) {
        return $GLOBALS['_MAX']['ADMIN_DB_LINK'];
    } elseif ($database == 'rawDatabase' && isset($GLOBALS['_MAX']['RAW_DB_LINK']) && is_resource($GLOBALS['_MAX']['RAW_DB_LINK'])) {
        return $GLOBALS['_MAX']['RAW_DB_LINK'];
    }
    // No connection exists, so create one
    $conf = $GLOBALS['_MAX']['CONF'];
    if (!empty($conf[$database])) {
        $dbConf = $conf[$database];
    } else {
        $dbConf = $conf['database'];
    }
    $dbParams = array();
    $dbParams[] = 'port=' . (isset($dbConf['port']) ? $dbConf['port'] : 5432);
    $dbParams[] = !empty($dbConf['protocol']) && $dbConf['protocol'] == 'unix' ? '' : 'host=' . $dbConf['host'];
    $dbParams[] = empty($dbConf['username']) ? '' : 'user='******'username'];
    $dbParams[] = empty($dbConf['password']) ? '' : 'password='******'password'];
    $dbParams[] = 'dbname=' . $dbConf['name'];
    if ($dbConf['persistent']) {
        $dbLink = @pg_pconnect(join(' ', $dbParams));
    } else {
        $dbLink = @pg_connect(join(' ', $dbParams));
    }
    if ($dbLink && !empty($conf['databasePgsql']['schema'])) {
        @pg_query($dbLink, "SET search_path='{$conf['databasePgsql']['schema']}'");
    }
    if ($dbLink && !empty($conf['databaseCharset']['checkComplete']) && !empty($conf['databaseCharset']['clientCharset'])) {
        @pg_client_encoding($dbLink, $conf['databaseCharset']['clientCharset']);
    }
    return $dbLink;
}
Example #15
0
 function sql_db($sqlserver, $sqluser, $sqlpassword, $database, $persistency = true)
 {
     $this->connect_string = "";
     if ($sqluser) {
         $this->connect_string .= "user={$sqluser} ";
     }
     if ($sqlpassword) {
         $this->connect_string .= "password={$sqlpassword} ";
     }
     if ($sqlserver) {
         if (ereg(":", $sqlserver)) {
             list($sqlserver, $sqlport) = split(":", $sqlserver);
             $this->connect_string .= "host={$sqlserver} port={$sqlport} ";
         } else {
             if ($sqlserver != "localhost") {
                 $this->connect_string .= "host={$sqlserver} ";
             }
         }
     }
     if ($database) {
         $this->dbname = $database;
         $this->connect_string .= "dbname={$database}";
     }
     $this->persistency = $persistency;
     $this->db_connect_id = $this->persistency ? pg_pconnect($this->connect_string) : pg_connect($this->connect_string);
     return $this->db_connect_id ? $this->db_connect_id : false;
 }
Example #16
0
 function sql_db($sqlserver, $sqluser, $sqlpassword, $database, $persistency = true)
 {
     $this->connect_string = "";
     if ($sqluser) {
         $this->connect_string .= "user={$sqluser} ";
     }
     if ($sqlpassword) {
         $this->connect_string .= "password={$sqlpassword} ";
     }
     if ($sqlserver) {
         if (ereg(":", $sqlserver)) {
             list($sqlserver, $sqlport) = split(":", $sqlserver);
             $this->connect_string .= "host={$sqlserver} port={$sqlport} ";
         } else {
             if ($sqlserver != "localhost") {
                 $this->connect_string .= "host={$sqlserver} ";
             }
         }
     }
     if ($database) {
         $this->dbname = $database;
         $this->connect_string .= "dbname={$database}";
     }
     $this->persistency = $persistency;
     $this->db_connect_id = $this->persistency ? pg_pconnect($this->connect_string) : pg_connect($this->connect_string);
     $this->server = $sqlserver;
     $this->prefix = isset($GLOBALS['config']['prefix']) ? $GLOBALS['config']['prefix'] : '';
     $this->root = WWW_PREFIX;
     $this->cache_path = $this->root . '/' . $this->cache_path;
     $this->cache_enabled = isset($GLOBALS['config']['disable_sql_cache']) ? false : true;
     return $this->db_connect_id ? $this->db_connect_id : false;
 }
Example #17
0
function Open($dbType, $connectType = "c", $connect, $username = "", $password = "", $dbName)
{
    switch ($dbType) {
        case "mssql":
            if ($connectType == "c") {
                $idCon = mssql_connect($connect, $username, $password);
            } else {
                $idCon = mssql_pconnect($connect, $username, $password);
            }
            mssql_select_db($dbName);
            break;
        case "mysql":
            if ($connectType == "c") {
                $idCon = @mysql_connect($connect, $username, $password);
            } else {
                $idCon = @mysql_pconnect($connect, $username, $password);
            }
            $idCon1 = mysql_select_db($dbName, $idCon);
            break;
        case "pg":
            if ($connectType == "c") {
                $idCon = pg_connect($connect . " user="******" password="******" dbname=" . $dbName);
            } else {
                $idCon = pg_pconnect($connect . " user="******" password="******" dbname=" . $dbName);
            }
            break;
        default:
            $idCon = 0;
            break;
    }
    return $idCon;
}
Example #18
0
 function DBLayer($db_host, $db_username, $db_password, $db_name, $db_prefix, $p_connect)
 {
     $this->prefix = $db_prefix;
     if ($db_host != '') {
         if (strpos($db_host, ':') !== false) {
             list($db_host, $dbport) = explode(':', $db_host);
             $connect_str[] = 'host=' . $db_host . ' port=' . $dbport;
         } else {
             if ($db_host != 'localhost') {
                 $connect_str[] = 'host=' . $db_host;
             }
         }
     }
     if ($db_name) {
         $connect_str[] = 'dbname=' . $db_name;
     }
     if ($db_username != '') {
         $connect_str[] = 'user='******'') {
         $connect_str[] = 'password='******' ', $connect_str));
     } else {
         $this->link_id = @pg_connect(implode(' ', $connect_str));
     }
     if (!$this->link_id) {
         error('Unable to connect to PostgreSQL server', __FILE__, __LINE__);
     } else {
         return $this->link_id;
     }
 }
Example #19
0
 /**
  * Creates connection to database.
  * @param array $config Configuration options
  * @throws DriverException
  */
 public function connect(array $config)
 {
     $defaults = array('resource' => null, 'persistent' => false, 'charset' => 'utf8');
     $config += $defaults;
     if (isset($config['string'])) {
         $string = $config['string'];
     } else {
         // String generation
         $string = '';
         foreach (array('host', 'hostaddr', 'port', 'dbname', 'user', 'password', 'connect_timeout', 'options', 'sslmode', 'service') as $cfg) {
             if (isset($config[$cfg])) {
                 $string .= "{$cfg}={$config[$cfg]} ";
             }
         }
     }
     // Connect
     if (is_resource($config['resource'])) {
         $connection = $config['resource'];
     } elseif ($config['persistent']) {
         $connection = @pg_pconnect($string, PGSQL_CONNECT_FORCE_NEW);
     } else {
         $connection = @pg_connect($string, PGSQL_CONNECT_FORCE_NEW);
     }
     if (!is_resource($connection)) {
         throw new DriverException("Connection to database failed.");
     }
     $this->resource = $connection;
     // Encoding
     @pg_set_client_encoding($this->resource, $config['charset']);
     // Schema
     if (isset($config['schema'])) {
         $this->runQuery('SET search_path TO "' . $config['schema'] . '"');
     }
 }
Example #20
0
 /**
  * {@inheritDoc}
  */
 function sql_connect($sqlserver, $sqluser, $sqlpassword, $database, $port = false, $persistency = false, $new_link = false)
 {
     $connect_string = '';
     if ($sqluser) {
         $connect_string .= "user={$sqluser} ";
     }
     if ($sqlpassword) {
         $connect_string .= "password={$sqlpassword} ";
     }
     if ($sqlserver) {
         // $sqlserver can carry a port separated by : for compatibility reasons
         // If $sqlserver has more than one : it's probably an IPv6 address.
         // In this case we only allow passing a port via the $port variable.
         if (substr_count($sqlserver, ':') === 1) {
             list($sqlserver, $port) = explode(':', $sqlserver);
         }
         if ($sqlserver !== 'localhost') {
             $connect_string .= "host={$sqlserver} ";
         }
         if ($port) {
             $connect_string .= "port={$port} ";
         }
     }
     $schema = '';
     if ($database) {
         $this->dbname = $database;
         if (strpos($database, '.') !== false) {
             list($database, $schema) = explode('.', $database);
         }
         $connect_string .= "dbname={$database}";
     }
     $this->persistency = $persistency;
     if ($this->persistency) {
         if (!function_exists('pg_pconnect')) {
             $this->connect_error = 'pg_pconnect function does not exist, is pgsql extension installed?';
             return $this->sql_error('');
         }
         $collector = new \phpbb\error_collector();
         $collector->install();
         $this->db_connect_id = !$new_link ? @pg_pconnect($connect_string) : @pg_pconnect($connect_string, PGSQL_CONNECT_FORCE_NEW);
     } else {
         if (!function_exists('pg_connect')) {
             $this->connect_error = 'pg_connect function does not exist, is pgsql extension installed?';
             return $this->sql_error('');
         }
         $collector = new \phpbb\error_collector();
         $collector->install();
         $this->db_connect_id = !$new_link ? @pg_connect($connect_string) : @pg_connect($connect_string, PGSQL_CONNECT_FORCE_NEW);
     }
     $collector->uninstall();
     if ($this->db_connect_id) {
         if ($schema !== '') {
             @pg_query($this->db_connect_id, 'SET search_path TO ' . $schema);
         }
         return $this->db_connect_id;
     }
     $this->connect_error = $collector->format_errors();
     return $this->sql_error('');
 }
Example #21
0
function conectarse()
{
    if (!($conexion = pg_pconnect("host=localhost port=5432 dbname=aplicacion_dow user=postgres password=root"))) {
        exit;
    } else {
    }
    return $conexion;
}
Example #22
0
function conectarse()
{
    if (!($conexion = pg_pconnect("host=localhost port=5432 dbname=comisariato_nuevo user=postgres password=sisweb"))) {
        exit;
    } else {
    }
    return $conexion;
}
Example #23
0
 /**
  * Connect to the database.
  * @param str[] config
  */
 function connect($config)
 {
     $connString = sprintf('host=%s dbname=%s user=%s password=%s', $config['server'], $config['database'], $config['username'], $config['password']);
     if ($this->db = pg_pconnect($connString)) {
         return TRUE;
     }
     return FALSE;
 }
Example #24
0
 /**
  * Connect to the database server and select the database
  */
 protected function connect()
 {
     $strConnection = sprintf('host=%s port=%s user=%s password=%s dbname=%s', $GLOBALS['TL_CONFIG']['dbHost'], $GLOBALS['TL_CONFIG']['dbPort'], $GLOBALS['TL_CONFIG']['dbUser'], $GLOBALS['TL_CONFIG']['dbPass'], $GLOBALS['TL_CONFIG']['dbDatabase']);
     if ($GLOBALS['TL_CONFIG']['dbPconnect']) {
         $this->resConnection = @pg_pconnect($strConnection);
     } else {
         $this->resConnection = @pg_connect($strConnection);
     }
 }
Example #25
0
 static function getConnection()
 {
     // Create connection
     $conn = pg_pconnect("host=" . apiDB::$DBservername . " dbname=" . apiDB::$dbname . " user="******" password="******"Database connection failed. ");
     }
     return $conn;
 }
Example #26
0
File: DB.php Project: ryzhov/ATS0
 private static function connect()
 {
     if (!isset(self::$connection)) {
         if ((self::$connection = pg_pconnect(DB_URL)) === FALSE) {
             self::$connection = null;
             throw new DBException(pg_last_error());
         }
     }
 }
Example #27
0
 public function Connect($host, $user, $pass, $db)
 {
     $this->link = @pg_pconnect("host={$host} dbname={$db} user={$user} password={$pass}");
     if (!is_resource($this->link)) {
         throw new DBA_Exception(DBA::E_INVALID_SERVER, "pgsql://{$user}:{$pass}@{$host}.{$db}");
         return FALSE;
     }
     return TRUE;
 }
Example #28
0
 function connect()
 {
     // Connect to the database using pgsql
     $this->database = DB_NAME;
     $this->conn = @pg_pconnect("host=" . DB_HOST . " port=" . DB_PORT . " user="******" password="******"dbname=" . $this->database);
     if (!$this->conn) {
         die('<BR>Message : Unable to connect to the database.<BR>');
     }
 }
Example #29
0
 private function getConnection()
 {
     $host = "127.0.0.1";
     $port = "5432";
     $db = "scuptel";
     $user = "******";
     $pass = "******";
     return pg_pconnect("host={$host} port={$port} dbname={$db} user={$user} password={$pass}");
 }
 /**
  * Konstruktor
  */
 public function __construct()
 {
     if (!($this->conn_moodle = pg_pconnect(CONN_STRING_MOODLE))) {
         $this->errormsg = 'Fehler beim Herstellen der Moodle Verbindung';
         return false;
     } else {
         return true;
     }
 }