blob: ea546bb4923af3d96930bcd306b091359451d0b3 [file] [log] [blame]
MG Mud User88f12472016-06-24 23:31:02 +02001OPTIONAL
2SYNOPSIS
Zesstra715ec202025-07-09 22:18:31 +02003 int pg_connect(string conn, string fun)
4 int pg_connect(string conn, string fun, string|object obj,
5 mixed extra, ...)
6 int pg_connect(string conn, closure cl, mixed extra, ...)
MG Mud User88f12472016-06-24 23:31:02 +02007
8DESCRIPTION
9 Open a database connection as directed by <conn>, and assign the
10 callback function <fun>/<cl> with the optional <extra> parameters
11 to it.
12
13 The object holding the callback function becomes the controlling
14 object; obiously it is an error to assign more than one connection
15 to the same controlling object.
16
17 The <conn> string is in the format accepted by Postgres'
18 PQconnectStart() API functions. Pass an empty string to use the
19 default options, or a string holding the '<key>=<value>' options
20 separated by whitespace.
21
22 The most useful options are:
23 dbname: The database name
24 user: The user name to connect as.
25 password: Password to be used.
26
27 Return 0 on success, and -1 on failure.
28
29 The function is available only if the driver is compiled with
30 PostgreSQL support. In that case, __PGSQL__ is defined.
31
32 The efun triggers a privilege violation ("pgsql", "pg_connect").
33
34HISTORY
35 Added in 3.3.445.
36 LDMud 3.3.640 added the privilege violation.
37
38SEE ALSO
39 pgsql(C), pg_query(E), pg_pending(E), pg_conv_string(E), pg_close(E),
40 privilege_violation(M)