class COPY (View source)

Fast import/export using COPY.

Constants

FROM_STDIN

Start a COPY operation from STDIN to the PostgreSQL server.

TO_STDOUT

Start a COPY operation from the server to STDOUT.

Properties

Connection read-only $connection

The connection to the PostgreSQL server.

string read-only $expression

The expression of the COPY statement used to start the operation.

int read-only $direction

The drection of the COPY operation (pq\COPY::FROM_STDIN or pq\COPY::TO_STDOUT).

string read-only $options

Any additional options used to start the COPY operation.

Methods

__construct(Connection $conn, string $expression, int $direction, string $options = null)

Start a COPY operation.

end(string $error = null)

End the COPY operation to the server during pq\Result::COPY_IN state.

bool
get(string $data)

Receive data from the server during pq\Result::COPY_OUT state.

put(string $data)

Send data to the server during pq\Result::COPY_IN state.

Details

__construct(Connection $conn, string $expression, int $direction, string $options = null)

Start a COPY operation.

Parameters

Connection $conn

The connection to use for the COPY operation.

string $expression

The expression generating the data to copy.

int $direction

Data direction (pq\COPY::FROM_STDIN or pq\COPY::TO_STDOUT).

string $options

Any COPY options (see the official PostgreSQL documentation for details.

Exceptions

InvalidArgumentException
BadMethodCallException
RuntimeException

end(string $error = null)

End the COPY operation to the server during pq\Result::COPY_IN state.

Parameters

string $error

If set, the COPY operation will abort with provided message.

Exceptions

InvalidArgumentException
BadMethodCallException
RuntimeException

bool get(string $data)

Receive data from the server during pq\Result::COPY_OUT state.

Parameters

string $data

Data read from the server.

Return Value

bool success.

Exceptions

InvalidArgumentException
BadMethodCallException
RuntimeException

put(string $data)

Send data to the server during pq\Result::COPY_IN state.

Parameters

string $data

Data to send to the server.

Exceptions

InvalidArgumentException
BadMethodCallException
RuntimeException