Rev 1220 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1220 | Rev 1262 | ||
---|---|---|---|
Line 130... | Line 130... | ||
130 | } else { |
130 | } else { |
131 | list($hostname, $port) = explode(':', "$host:5432"); |
131 | list($hostname, $port) = explode(':', "$host:5432"); |
132 | } |
132 | } |
133 | 133 | ||
134 | $connection_string = array(); |
134 | $connection_string = array(); |
135 | if ($hostname != '') $connection_string[] = "host=$hostname"; |
135 | if ($hostname != '') $connection_string[] = "host='".str_replace("'", "\\'", $hostname)."'"; |
136 | if ($username != '') $connection_string[] = "user=$username"; |
136 | if ($username != '') $connection_string[] = "user='".str_replace("'", "\\'", $username)."'"; |
137 | if ($password != '') $connection_string[] = "password=$password"; |
137 | if ($password != '') $connection_string[] = "password='".str_replace("'", "\\'", $password)."'"; |
138 | if ($port != '') $connection_string[] = "port=$port"; |
138 | if ($port != '') $connection_string[] = "port='".str_replace("'", "\\'", $port)."'"; |
139 | if ($database != '') $connection_string[] = "dbname=$database"; |
139 | if ($database != '') $connection_string[] = "dbname='".str_replace("'", "\\'", $database)."'"; |
140 | 140 | ||
141 | // We need to use PGSQL_CONNECT_FORCE_NEW because we require two connectoins (for isolated log message queries) |
141 | // We need to use PGSQL_CONNECT_FORCE_NEW because we require two connectoins (for isolated log message queries) |
142 | $this->conn = pg_connect(implode(' ', $connection_string), PGSQL_CONNECT_FORCE_NEW); |
142 | $this->conn = pg_connect(implode(' ', $connection_string), PGSQL_CONNECT_FORCE_NEW); |
143 | } finally { |
143 | } finally { |
144 | # TODO: this does not seem to work?! (at least not for CLI) |
144 | # TODO: this does not seem to work?! (at least not for CLI) |