Overview

Namespaces

  • PommProject
    • Cli
      • Command
      • Exception
    • Foundation
      • Client
      • Converter
        • Geometry
        • Type
      • Exception
      • Inspector
      • Listener
      • Observer
      • PreparedQuery
      • QueryManager
      • Session
      • Tester
    • ModelManager
      • Converter
      • Exception
      • Generator
      • Model
        • FlexibleEntity
        • ModelTrait
      • ModelLayer
      • Tester

Classes

  • Connection
  • ConnectionConfigurator
  • ResultHandler
  • Session
  • SessionBuilder
  • Overview
  • Namespace
  • Class

Class Connection

Connection

Manage connection through a resource handler.

Namespace: PommProject\Foundation\Session
Package: Foundation
Copyright: 2014 - 2015 Grégoire HUBERT
Author: Grégoire HUBERT
License: {@link http://opensource.org/licenses/mit-license.php}
Located at Session/Connection.php
Methods summary
public
# __construct( string $dsn, array $configuration = [] )

__construct

__construct

Constructor. Test if the given DSN is valid.

Parameters

$dsn
$configuration

Throws

PommProject\Foundation\Exception\ConnectionException
if pgsql extension is missing
public PommProject\Foundation\Session\Connection
# close( )

close

close

Close the connection if any.

Returns

PommProject\Foundation\Session\Connection
$this
public PommProject\Foundation\Session\Connection
# addConfiguration( array $configuration )

addConfiguration

addConfiguration

Add configuration settings. If settings exist, they are overridden.

Parameters

$configuration

Returns

PommProject\Foundation\Session\Connection
$this

Throws

PommProject\Foundation\Exception\ConnectionException
if connection is already up.
public PommProject\Foundation\Session\Connection
# addConfigurationSetting( string $name, string $value )

addConfigurationSetting

addConfigurationSetting

Add or override a configuration definition.

Parameters

$name
$value

Returns

PommProject\Foundation\Session\Connection
protected resource
# getHandler( )

getHandler

getHandler

Return the connection handler. If no connection are open, it opens one.

Returns

resource

Throws

PommProject\Foundation\Exception\ConnectionException
if connection is open in a bad state.
protected boolean
# hasHandler( )

hasHandler

hasHandler

Tell if a handler is set or not.

Returns

boolean
public integer
# getConnectionStatus( )

getConnectionStatus

getConnectionStatus

Return a connection status.

Returns

integer
public integer
# getTransactionStatus( )

getTransactionStatus

getTransactionStatus

Return the current transaction status. Return a PHP constant.

Returns

integer

See

http://fr2.php.net/manual/en/function.pg-transaction-status.php
protected PommProject\Foundation\Session\Connection
# sendConfiguration( )

sendConfiguration

sendConfiguration

Send the configuration settings to the server.

Returns

PommProject\Foundation\Session\Connection
$this
public PommProject\Foundation\Session\ResultHandler|array
# executeAnonymousQuery( string $sql )

executeAnonymousQuery

executeAnonymousQuery

Performs a raw SQL query

Parameters

$sql
The sql statement to execute.

Returns

PommProject\Foundation\Session\ResultHandler|array
protected PommProject\Foundation\Session\ResultHandler|array
# getQueryResult( string $sql = null )

getQueryResult

getQueryResult

Get an asynchronous query result. The only reason for the SQL query to be passed as parameter is to throw a meaningful exception when an error is raised. Since it is possible to send several queries at a time, This method can return an array of ResultHandler.

Parameters

$sql
null)

Returns

PommProject\Foundation\Session\ResultHandler|array

Throws

PommProject\Foundation\Exception\ConnectionException
if no response are available.
PommProject\Foundation\Exception\SqlException
if the result is an error.
public string
# escapeIdentifier( string $string )

escapeIdentifier

escapeIdentifier

Escape database object's names. This is different from value escaping as objects names are surrounded by double quotes. API function does provide a nice escaping with -- hopefully -- UTF8 support.

Parameters

$string
The string to be escaped.

Returns

string
the escaped string.

See

http://www.postgresql.org/docs/current/static/sql-syntax-lexical.html
public string
# escapeLiteral( string $string )

escapeLiteral

escapeLiteral

Escape a text value.

Parameters

$string
The string to be escaped

Returns

string
the escaped string.
public string
# escapeBytea( string $word )

escapeBytea

escapeBytea

Wrap pg_escape_bytea

Parameters

$word

Returns

string
public string
# unescapeBytea( string $bytea )

unescapeBytea

unescapeBytea

Unescape PostgreSQL bytea.

Parameters

$bytea

Returns

string
public PommProject\Foundation\Session\ResultHandler
# sendQueryWithParameters( string $query, array $parameters = [] )

sendQueryWithParameters

sendQueryWithParameters

Execute a asynchronous query with parameters and send the results.

Parameters

$query
$parameters

Returns

PommProject\Foundation\Session\ResultHandler
query result wrapper

Throws

PommProject\Foundation\Exception\SqlException
public PommProject\Foundation\Session\Connection
# sendPrepareQuery( string $identifier, string $sql )

sendPrepareQuery

sendPrepareQuery

Send a prepare query statement to the server.

Parameters

$identifier
$sql

Returns

PommProject\Foundation\Session\Connection
$this
protected PommProject\Foundation\Session\Connection
# testQuery( mixed $query_return, string $sql )

testQueryAndGetResult

testQueryAndGetResult

Factor method to test query return and summon getQueryResult().

Parameters

$query_return
$sql

Returns

PommProject\Foundation\Session\Connection
$this

Throws

PommProject\Foundation\Exception\ConnectionException
public PommProject\Foundation\Session\ResultHandler
# sendExecuteQuery( string $identifier, array $parameters = [], string $sql = '' )

sendExecuteQuery

sendExecuteQuery

Execute a prepared statement. The optional SQL parameter is for debugging purposes only.

Parameters

$identifier
$parameters
$sql

Returns

PommProject\Foundation\Session\ResultHandler
public string
# getClientEncoding( )

getClientEncoding

getClientEncoding

Return the actual client encoding.

Returns

string
public PommProject\Foundation\Session\Connection
# setClientEncoding( string $encoding )

setClientEncoding

setClientEncoding

Set client encoding.

Parameters

$encoding

Returns

PommProject\Foundation\Session\Connection
$this;
public array|null
# getNotification( )

getNotification

getNotification

Get pending notifications. If no notifications are waiting, NULL is returned. Otherwise an associative array containing the optional data and de backend's PID is returned.

Returns

array|null
Constants summary
integer CONNECTION_STATUS_NONE
# 0
integer CONNECTION_STATUS_GOOD
# 1
integer CONNECTION_STATUS_BAD
# 2
integer CONNECTION_STATUS_CLOSED
# 3
string ISOLATION_READ_COMMITTED
# "READ COMMITTED"
string ISOLATION_REPEATABLE_READ
# "REPEATABLE READ"
string ISOLATION_SERIALIZABLE
# "SERIALIZABLE"
string CONSTRAINTS_DEFERRED
# "DEFERRED"
string CONSTRAINTS_IMMEDIATE
# "IMMEDIATE"
string ACCESS_MODE_READ_ONLY
# "READ ONLY"
string ACCESS_MODE_READ_WRITE
# "READ WRITE"
Properties summary
protected $handler
#
protected $configurator
#
API documentation generated by ApiGen