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