first connection docs
[mdref/mdref-pq] / pq / Connection.md
1 # class pq\Connection
2
3 A class representing a connection to the PostgreSQL server.
4
5 See the [General Usage](pq/Connection/: General Usage) page for an introduction on how to use this class.
6
7 ## Constants:
8 ### Connection Flags:
9 * PERSISTENT
10 (Re-)open a persistent connection.
11 * ASYNC
12 If the connection is not already open, perform the connection attempt [asynchronously](pq/Connection/: Asynchronous Usage).
13
14 ### Connection Status:
15 * OK
16 Everything well; if a connection has been newly and synchronously created, the connection will always have this status right after creation.
17 * BAD
18 Broken connection; consider pq\Connection::reset() or recreation.
19 * STARTED
20 Waiting for connection to be made.
21 * MADE
22 Connection OK; waiting to send.
23 * AWAITING_RESPONSE
24 Waiting for a response from the server.
25 * AUTH_OK
26 Received authentication; waiting for backend start-up to finish.
27 * SSL_STARTUP
28 Negotiating SSL encryption.
29 * SETENV
30 Negotiating environment-driven parameter settings.
31
32 ### Transaction Status:
33 * TRANS_IDLE
34 No active transaction.
35 * TRANS_ACTIVE
36 A transaction command is in progress.
37 * TRANS_INTRANS
38 Idling in a valid transcation block.
39 * TRANS_INERROR
40 Idling in a failed transaction block.
41 * TRANS_UNKNOWN
42 Bad connection.
43
44 ### Polling Status:
45 * POLLING_FAILED
46 The connection procedure has failed.
47 * POLLING_READING
48 Select for read-readiness.
49 * POLLING_WRITING
50 Select for write-readiness.
51 * POLLING_OK
52 The connection has been successfully made.
53
54 ### Event Listener Types:
55 * EVENT_NOTICE
56 Register the event handler for notices.
57 * EVENT_RESULT
58 Register the event handler for any created results.
59 * EVENT_RESET
60 Register the event handler for connection resets.
61
62
63 ## Properties:
64 * public (readonly) $status
65 A [connection status constant](pq/Connection#Connection.Status:) value.
66 * public (readonly) $transactionStatus
67 A [transaction status constant](pq/Connection#Transaction.Status:) value.
68 * public (readonly) $socket
69 The server socket resource.
70 * public (readonly) $busy
71 Whether the connection is busy with [asynchronous operations](pq/Connection/: Asynchronous Usage).
72 * public (readonly) $errorMessage
73 Any error message on failure.
74 * public $encoding = NULL
75 Connection character set.
76 * public $unbuffered = FALSE
77 Whether to fetch results in unbuffered mode, i.e. each row generates a distinct pq\Result.
78
79 ### Connection Information:
80 * public (readonly) $db
81 The database name of the connection.
82 * public (readonly) $user
83 The user name of the connection.
84 * public (readonly) $pass
85 The password of the connection.
86 * public (readonly) $host
87 The server host name of the connection.
88 * public (readonly) $port
89 The port of the connection.
90 * public (readonly) $options
91 The command-line options passed in the connection request.