function DoConnect($database_name, $persistent) { $function = $persistent ? "pg_pconnect" : "pg_connect"; if (!function_exists($function)) { return $this->SetError("Do Connect", "PostgreSQL support is not available in this PHP configuration"); } if (strlen($database_name) == 0) { return $this->SetError("Do Connect", "it was not specified a PostgreSQL database to connect"); } Putenv("PGUSER="******"PGPASSWORD="******"PGDATESTYLE=ISO"); $port = isset($this->options["Port"]) ? $this->options["Port"] : ""; if (($connection = @$function($this->host, strval($port), $database_name)) > 0) { return $connection; } return $this->SetError("Do Connect", isset($php_errormsg) ? $php_errormsg : "Could not connect to PostgreSQL server"); }
function Connect($dba) { if (!$this->auto_commit && !isset($this->options["Logging"])) { return $this->SetError("Connect", "transactions are not supported on databases without logging"); } if ($dba) { $user = isset($this->options[$option = "DBAUser"]) ? $this->options[$option = "DBAUser"] : ""; $password = isset($this->options[$option = "DBAPassword"]) ? $this->options[$option = "DBAPassword"] : ""; $database_name = ""; $persistent = 0; } else { $user = $this->user; $password = $this->password; $database_name = $this->database_name; $persistent = $this->persistent; } if (!strcmp($user, "")) { return $this->SetError("Connect", "it was not specified a non-empty Informix user name"); } if ($this->connection != 0) { if (strcmp($this->connected_host, $this->host) || strcmp($this->connected_user, $user) || strcmp($this->connected_password, $password) || $this->opened_persistent != $persistent) { ifx_Close($this->connection); $this->connection = 0; $this->connected_database_name = ""; $this->affected_rows = -1; } } if ($this->connection == 0) { $function = $this->persistent ? "ifx_pconnect" : "ifx_connect"; if (!function_exists($function)) { return $this->SetError("Connect", "Informix support is not available in this PHP configuration"); } Putenv("INFORMIXSERVER=" . $this->host); Putenv("DBDATE=Y4MD-"); if (($this->connection = @$function("@" . $this->host, $user, $password)) <= 0) { return $this->SetIFXError("Connect", "Could not connect to the Informix server"); } $this->connected_host = $this->host; $this->connected_user = $user; $this->connected_password = $password; $this->opened_persistent = $persistent; $in_transaction = 0; $new_connection = 1; } else { $new_connection = 0; $in_transaction = !$this->auto_commit; } if (strcmp($this->connected_database_name, $database_name)) { if ($in_transaction && !$this->DoQuery("ROLLBACK") || !$this->DoQuery("DATABASE {$database_name}")) { $this->SetIFXError("Connect", "Could not set the Informix database"); ifx_Close($this->connection); $this->connection = 0; $this->connected_database_name = ""; $this->affected_rows = -1; return 0; } $new_connection = 1; $this->connected_database_name = $database_name; } if ($new_connection && !$this->auto_commit && strcmp($this->options["Logging"], "ANSI") && !$this->DoQuery("BEGIN")) { ifx_Close($this->connection); $this->connection = 0; $this->connected_database_name = ""; $this->affected_rows = -1; return 0; } $this->connected_host = $this->host; $this->connected_database_name = $database_name; $this->connected_user = $user; $this->connected_password = $password; $this->opened_persistent = $persistent; return 1; }