pq\Types docs
[mdref/mdref-pq] / pq / Connection / __construct.md
1 # void pq\Connection::__construct([string $dsn = ""[, int $flags = 0]])
2
3 Create a new PostgreSQL connection.
4 See also [General Usage](pq/Connection/: General Usage).
5
6 ## Params:
7 * Optional string $dsn = ""
8 A ***connection string*** as described [in the PostgreSQL documentation](http://www.postgresql.org/docs/current/static/libpq-connect.html#LIBPQ-CONNSTRING).
9 * Optional int $flags = 0
10 See [connection flag constants](pq/Connection#Connection.Flags:).
11
12 ## Throws:
13
14 * pq\Exception\InvalidArgumentException
15 * pq\Exception\BadMethodCallException
16 * pq\Exception\RuntimeException
17
18 ## Example:
19
20 <?php
21
22 $connection = new pq\Connection("dbname=test user=test password=test",
23 pq\Connection::ASYNC | pq\Connection::PERSISTENT);
24
25 ?>
26
27