source: www/manuals/PHP_manual/function.pg-connect.html@ 1

Last change on this file since 1 was 1, checked in by george, 17 years ago

Prvotní import všeho

File size: 5.2 KB
Line 
1<HTML
2><HEAD
3><TITLE
4>pg_connect</TITLE
5><META
6NAME="GENERATOR"
7CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK
8REL="HOME"
9TITLE="Manuál PHP"
10HREF="index.html"><LINK
11REL="UP"
12TITLE="PostgreSQL functions"
13HREF="ref.pgsql.html"><LINK
14REL="PREVIOUS"
15TITLE="pg_close"
16HREF="function.pg-close.html"><LINK
17REL="NEXT"
18TITLE="pg_connection_busy"
19HREF="function.pg-connection-busy.html"><META
20HTTP-EQUIV="Content-type"
21CONTENT="text/html; charset=ISO-8859-2"></HEAD
22><BODY
23CLASS="refentry"
24BGCOLOR="#FFFFFF"
25TEXT="#000000"
26LINK="#0000FF"
27VLINK="#840084"
28ALINK="#0000FF"
29><DIV
30CLASS="NAVHEADER"
31><TABLE
32SUMMARY="Header navigation table"
33WIDTH="100%"
34BORDER="0"
35CELLPADDING="0"
36CELLSPACING="0"
37><TR
38><TH
39COLSPAN="3"
40ALIGN="center"
41>Manuál PHP</TH
42></TR
43><TR
44><TD
45WIDTH="10%"
46ALIGN="left"
47VALIGN="bottom"
48><A
49HREF="function.pg-close.html"
50ACCESSKEY="P"
51>Pøedcházející</A
52></TD
53><TD
54WIDTH="80%"
55ALIGN="center"
56VALIGN="bottom"
57></TD
58><TD
59WIDTH="10%"
60ALIGN="right"
61VALIGN="bottom"
62><A
63HREF="function.pg-connection-busy.html"
64ACCESSKEY="N"
65>Dal¹í</A
66></TD
67></TR
68></TABLE
69><HR
70ALIGN="LEFT"
71WIDTH="100%"></DIV
72><H1
73><A
74NAME="function.pg-connect"
75></A
76>pg_connect</H1
77><DIV
78CLASS="refnamediv"
79><A
80NAME="AEN70005"
81></A
82><P
83> (PHP 3, PHP 4 )</P
84>pg_connect&nbsp;--&nbsp;Open a PostgreSQL connection</DIV
85><DIV
86CLASS="refsect1"
87><A
88NAME="AEN70008"
89></A
90><H2
91>Description</H2
92>resource <B
93CLASS="methodname"
94>pg_connect</B
95> ( string connection_string)<BR
96></BR
97><P
98>&#13; <B
99CLASS="function"
100>pg_connect()</B
101> returns a connection resource
102 that is needed by other PostgreSQL functions.
103 </P
104><P
105>&#13; <B
106CLASS="function"
107>pg_connect()</B
108> opens a connection to a
109 PostgreSQL database specified by the
110 <TT
111CLASS="parameter"
112><I
113>connection_string</I
114></TT
115>. It returns a connection
116 resource on success. It returns <TT
117CLASS="constant"
118><B
119>FALSE</B
120></TT
121> if the connection could
122 not be made. <TT
123CLASS="parameter"
124><I
125>connection_string</I
126></TT
127> should be
128 a quoted string.
129 <TABLE
130WIDTH="100%"
131BORDER="0"
132CELLPADDING="0"
133CELLSPACING="0"
134CLASS="EXAMPLE"
135><TR
136><TD
137><DIV
138CLASS="example"
139><A
140NAME="AEN70023"
141></A
142><P
143><B
144>Pøíklad 1. Using pg_connect</B
145></P
146><TABLE
147BORDER="0"
148BGCOLOR="#E0E0E0"
149CELLPADDING="5"
150><TR
151><TD
152><PRE
153CLASS="php"
154>&#60;?php
155$dbconn = pg_connect ("dbname=mary");
156//connect to a database named "mary"
157$dbconn2 = pg_connect ("host=localhost port=5432 dbname=mary");
158// connect to a database named "mary" on "localhost" at port "5432"
159$dbconn3 = pg_connect ("host=sheep port=5432 dbname=mary user=lamb password=foo");
160//connect to a database named "mary" on the host "sheep" with a username and password
161$conn_string = "host=sheep port=5432 dbname=test user=lamb password=bar";
162$dbconn4 = pg_connect ($conn_string);
163//connect to a database named "test" on the host "sheep" with a username and password
164?&#62;</PRE
165></TD
166></TR
167></TABLE
168></DIV
169></TD
170></TR
171></TABLE
172>
173 The arguments available for
174 <TT
175CLASS="parameter"
176><I
177>connection_string</I
178></TT
179> includes
180 <TT
181CLASS="parameter"
182><I
183>host</I
184></TT
185>, <TT
186CLASS="parameter"
187><I
188>port</I
189></TT
190>,
191 <TT
192CLASS="parameter"
193><I
194>tty</I
195></TT
196>, <TT
197CLASS="parameter"
198><I
199>options</I
200></TT
201>,
202 <TT
203CLASS="parameter"
204><I
205>dbname</I
206></TT
207>, <TT
208CLASS="parameter"
209><I
210>user</I
211></TT
212>, and
213 <TT
214CLASS="parameter"
215><I
216>password</I
217></TT
218>.
219 </P
220><P
221>&#13; If a second call is made to <B
222CLASS="function"
223>pg_connect()</B
224> with
225 the same <TT
226CLASS="parameter"
227><I
228>connection_string</I
229></TT
230>, no
231 new connection will be established, but instead, the connection
232 resource of the already opened connection will be returned. You
233 can have multiple connections to the same database if you use
234 different connection string.
235 </P
236><P
237>&#13; The old syntax with multiple parameters
238 <B
239CLASS="command"
240>$conn = pg_connect ("host", "port", "options", "tty", "dbname")
241 </B
242> has been deprecated.
243 </P
244><P
245>&#13; See also <A
246HREF="function.pg-pconnect.html"
247><B
248CLASS="function"
249>pg_pconnect()</B
250></A
251>,
252 <A
253HREF="function.pg-close.html"
254><B
255CLASS="function"
256>pg_close()</B
257></A
258>, <A
259HREF="function.pg-host.html"
260><B
261CLASS="function"
262>pg_host()</B
263></A
264>,
265 <A
266HREF="function.pg-port.html"
267><B
268CLASS="function"
269>pg_port()</B
270></A
271>, <A
272HREF="function.pg-tty.html"
273><B
274CLASS="function"
275>pg_tty()</B
276></A
277>,
278 <A
279HREF="function.pg-options.html"
280><B
281CLASS="function"
282>pg_options()</B
283></A
284> and <A
285HREF="function.pg-dbname.html"
286><B
287CLASS="function"
288>pg_dbname()</B
289></A
290>.
291 </P
292></DIV
293><DIV
294CLASS="NAVFOOTER"
295><HR
296ALIGN="LEFT"
297WIDTH="100%"><TABLE
298SUMMARY="Footer navigation table"
299WIDTH="100%"
300BORDER="0"
301CELLPADDING="0"
302CELLSPACING="0"
303><TR
304><TD
305WIDTH="33%"
306ALIGN="left"
307VALIGN="top"
308><A
309HREF="function.pg-close.html"
310ACCESSKEY="P"
311>Pøedcházející</A
312></TD
313><TD
314WIDTH="34%"
315ALIGN="center"
316VALIGN="top"
317><A
318HREF="index.html"
319ACCESSKEY="H"
320>Domù</A
321></TD
322><TD
323WIDTH="33%"
324ALIGN="right"
325VALIGN="top"
326><A
327HREF="function.pg-connection-busy.html"
328ACCESSKEY="N"
329>Dal¹í</A
330></TD
331></TR
332><TR
333><TD
334WIDTH="33%"
335ALIGN="left"
336VALIGN="top"
337>pg_close</TD
338><TD
339WIDTH="34%"
340ALIGN="center"
341VALIGN="top"
342><A
343HREF="ref.pgsql.html"
344ACCESSKEY="U"
345>Nahoru</A
346></TD
347><TD
348WIDTH="33%"
349ALIGN="right"
350VALIGN="top"
351>pg_connection_busy</TD
352></TR
353></TABLE
354></DIV
355></BODY
356></HTML
357>
Note: See TracBrowser for help on using the repository browser.