Bitrix API

PgsqlConnection extends Connection

Class Connection

Table of Contents

Constants

DEFERRED  = 2
FULLTEXT_MAXIMUM_LENGTH  = 900000
INDEX_FULLTEXT  = 'FULLTEXT'
INDEX_SPATIAL  = 'SPATIAL'
INDEX_UNIQUE  = 'UNIQUE'
PERSISTENT  = 1

Properties

$resource  : Connection

Methods

__construct()  : mixed
$configuration may contain following keys: <ul> <li>host <li>database <li>login <li>password <li>initCommand <li>options </ul>
add()  : int
Adds row to table and returns ID of the added row.
addMulti()  : int
clearCaches()  : void
Clears all internal caches which may be used by some dictionary functions.
commitTransaction()  : void
Commits started database transaction.
connect()  : void
Connects to the database.
connectionErrorHandler()  : mixed
createIndex()  : Result|false
Creates index on column(s)
createPrimaryIndex()  : Result
Creates primary index on column(s)
createQueryException()  : mixed
Creates an exception by the error code.
createTable()  : void
disableQueryExecuting()  : void
Temporary disables query executing. All queries being collected in disabledQueryExecutingDump
disconnect()  : void
Disconnects from the database.
dropColumn()  : void
Drops a column. This column must exist and must be not the part of primary constraint.
dropTable()  : void
Drops the table.
enableQueryExecuting()  : void
Enables query executing after it has been temporary disabled
executeSqlBatch()  : array<string|int, mixed>
Parses the string containing multiple queries and executes the queries one by one.
getAffectedRowsCount()  : int
Returns affected rows count from last executed query.
getConfiguration()  : array<string|int, mixed>
Returns the array with the connection parameters.
getDatabase()  : string
Returns database name.
getDbName()  : string
getDisabledQueryExecutingDump()  : null|array<string|int, string>
Returns queries that were collected while Query Executing was disabled and clears the dump.
getErrorCode()  : int|string
Returns the error code of the last failed database operation.
getErrorMessage()  : string
Returns error message of last failed database operation.
getHost()  : string
Returns database host.
getIndexName()  : string|null
Returns the name of an index.
getInsertedId()  : int
getLogin()  : string
Returns database login.
getMaxAllowedPacket()  : int
Returns max packet length to send to or receive from the database server.
getNodeId()  : string|null
Returns connection node identifier.
getPassword()  : string
Returns database password.
getResource()  : Connection
Returns the resource of the connection.
getSqlHelper()  : MysqliSqlHelper|PgsqlSqlHelper
Returns database-depended SqlHelper object.
getTableField()  : ScalarField|null
Returns an object for the single column according to the column type.
getTableFields()  : array<string|int, ScalarField>
Returns fields objects according to the columns of a table.
getTableFullTextFields()  : mixed
getTracker()  : null|SqlTracker
Returns an object with information about queries executed.
getType()  : string
Returns database type.
getVersion()  : array<string|int, mixed>
Returns connected database version.
isConnected()  : bool
Returns the state of the connection.
isDeferred()  : bool
Returns true if the connection is deferred.
isIndexExists()  : bool
Checks if an index exists.
isPersistent()  : bool
Returns true if the connection is persistent.
isQueryExecutingEnabled()  : bool
isTableExists()  : bool
Checks if a table exists.
isUtf8mb4()  : bool
Returns utfmb4 flag for the specific table/column.
lock()  : bool
Sets a global named lock. Currently only Mysql is supported.
parseSqlBatch()  : array<string|int, mixed>
Parses the text containing sqls into separate queries.
query()  : Result
Executes a query to the database.
queryExecute()  : void
Executes a query without returning result, i.e. INSERT, UPDATE, DELETE
queryScalar()  : string|null
Executes a query, fetches a row and returns single field value from the first column of the result.
renameTable()  : void
Renames the table. Renamed table must exist and new name must not be occupied by any database object.
rollbackTransaction()  : void
Rollbacks started database transaction.
setNodeId()  : void
Sets connection node identifier.
setTracker()  : void
Sets new sql tracker.
startTracker()  : SqlTracker
Starts collecting information about all queries executed.
startTransaction()  : void
Starts new database transaction.
stopTracker()  : void
Stops collecting information about all queries executed.
truncateTable()  : Result
Truncates all table data.
unlock()  : bool
Releases a global named lock. Currently only Mysql is supported.

Constants

FULLTEXT_MAXIMUM_LENGTH

public mixed FULLTEXT_MAXIMUM_LENGTH = 900000

INDEX_FULLTEXT

public mixed INDEX_FULLTEXT = 'FULLTEXT'

INDEX_SPATIAL

public mixed INDEX_SPATIAL = 'SPATIAL'

INDEX_UNIQUE

public mixed INDEX_UNIQUE = 'UNIQUE'

Properties

Methods

__construct()

$configuration may contain following keys: <ul> <li>host <li>database <li>login <li>password <li>initCommand <li>options </ul>

public __construct(array<string|int, mixed> $configuration) : mixed
Parameters
$configuration : array<string|int, mixed>

Array of Name => Value pairs.

add()

Adds row to table and returns ID of the added row.

public add(mixed $tableName, array<string|int, mixed> $data[, mixed $identity = "ID" ]) : int
Parameters
$tableName : mixed

Name of the table for insertion of new row.

$data : array<string|int, mixed>

Array of columnName => Value pairs.

$identity : mixed = "ID"

For Oracle only.

Tags
inheritDoc
Return values
int

addMulti()

public addMulti(string $tableName, array<string|int, mixed> $rows[, string $identity = "ID" ]) : int
Parameters
$tableName : string
$rows : array<string|int, mixed>
$identity : string = "ID"
Tags
throws
SqlQueryException
Return values
int

clearCaches()

Clears all internal caches which may be used by some dictionary functions.

public clearCaches() : void

commitTransaction()

Commits started database transaction.

public commitTransaction() : void
Tags
inheritDoc

connect()

Connects to the database.

public connect() : void

connectionErrorHandler()

public connectionErrorHandler(mixed $errno, mixed $errstr[, mixed $errfile = '' ][, mixed $errline = 0 ][, mixed $errcontext = null ]) : mixed
Parameters
$errno : mixed
$errstr : mixed
$errfile : mixed = ''
$errline : mixed = 0
$errcontext : mixed = null

createIndex()

Creates index on column(s)

public createIndex(mixed $tableName, mixed $indexName, mixed $columnNames[, mixed $columnLengths = null ][, mixed $indexType = null ]) : Result|false
Parameters
$tableName : mixed

Name of the table.

$indexName : mixed

Name of the new index.

$columnNames : mixed

Name of the column or array of column names to be included into the index.

$columnLengths : mixed = null
$indexType : mixed = null
Tags
inheritDoc
Return values
Result|false

createPrimaryIndex()

Creates primary index on column(s)

public createPrimaryIndex(string $tableName, string|array<string|int, string> $columnNames) : Result
APIYes
Parameters
$tableName : string

Name of the table.

$columnNames : string|array<string|int, string>

Name of the column or array of column names to be included into the index.

Tags
throws
SqlQueryException
Return values
Result

createQueryException()

Creates an exception by the error code.

public createQueryException([mixed $code = '' ][, mixed $databaseMessage = '' ][, mixed $query = '' ]) : mixed
Parameters
$code : mixed = ''
$databaseMessage : mixed = ''
$query : mixed = ''
Tags
inheritdoc

createTable()

public createTable(mixed $tableName, mixed $fields[, mixed $primary = [] ][, mixed $autoincrement = [] ]) : void
Parameters
$tableName : mixed

Name of the new table.

$fields : mixed

Array with columns descriptions.

$primary : mixed = []

Array with primary key column names.

$autoincrement : mixed = []

Which columns will be auto incremented ones.

Tags
inheritDoc

disableQueryExecuting()

Temporary disables query executing. All queries being collected in disabledQueryExecutingDump

public disableQueryExecuting() : void
APIYes
Tags
see
enableQueryExecuting
see
getDisabledQueryExecutingDump

disconnect()

Disconnects from the database.

public disconnect() : void

dropColumn()

Drops a column. This column must exist and must be not the part of primary constraint.

public dropColumn(string $tableName, string $columnName) : void

and must be not the last one in the table.

Parameters
$tableName : string

Name of the table to which column will be dropped.

$columnName : string

Name of the column to be dropped.

Tags
throws
SqlQueryException

dropTable()

Drops the table.

public dropTable(mixed $tableName) : void
Parameters
$tableName : mixed

Name of the table to be dropped.

Tags
inheritDoc

enableQueryExecuting()

Enables query executing after it has been temporary disabled

public enableQueryExecuting() : void
APIYes
Tags
see
disableQueryExecuting

executeSqlBatch()

Parses the string containing multiple queries and executes the queries one by one.

public executeSqlBatch(string $sqlBatch[, bool $stopOnError = false ]) : array<string|int, mixed>

Queries delimiter depends on database type.

Parameters
$sqlBatch : string

String with queries, separated by database-specific delimiters.

$stopOnError : bool = false

Whether return after the first error.

Tags
see

SqlHelper->getQueryDelimiter

Return values
array<string|int, mixed>

Array of errors or empty array on success.

getAffectedRowsCount()

Returns affected rows count from last executed query.

public getAffectedRowsCount() : int
Tags
inheritDoc
Return values
int

getConfiguration()

Returns the array with the connection parameters.

public getConfiguration() : array<string|int, mixed>
Return values
array<string|int, mixed>

getDatabase()

Returns database name.

public getDatabase() : string
Return values
string

getDbName()

public getDbName() : string

Use getDatabase()

Return values
string

getDisabledQueryExecutingDump()

Returns queries that were collected while Query Executing was disabled and clears the dump.

public getDisabledQueryExecutingDump() : null|array<string|int, string>
APIYes
Tags
see
disableQueryExecuting
Return values
null|array<string|int, string>

getErrorCode()

Returns the error code of the last failed database operation.

public getErrorCode() : int|string
Tags
inheritDoc
Return values
int|string

getErrorMessage()

Returns error message of last failed database operation.

public getErrorMessage() : string
Tags
inheritDoc
Return values
string

getHost()

Returns database host.

public getHost() : string
Return values
string

getIndexName()

Returns the name of an index.

public getIndexName(mixed $tableName, array<string|int, mixed> $columns[, mixed $strict = false ]) : string|null
Parameters
$tableName : mixed

A table name.

$columns : array<string|int, mixed>

An array of columns in the index.

$strict : mixed = false

The flag indicating that the columns in the index must exactly match the columns in the $arColumns parameter.

Tags
inheritDoc
Return values
string|null

Name of the index or null if the index doesn't exist.

getInsertedId()

public getInsertedId() : int
Tags
inheritDoc
Return values
int

getLogin()

Returns database login.

public getLogin() : string
Return values
string

getMaxAllowedPacket()

Returns max packet length to send to or receive from the database server.

public getMaxAllowedPacket() : int
Return values
int

getNodeId()

Returns connection node identifier.

public getNodeId() : string|null
Return values
string|null

getPassword()

Returns database password.

public getPassword() : string
Return values
string

getResource()

Returns the resource of the connection.

public getResource() : Connection
Return values
Connection

getTableField()

Returns an object for the single column according to the column type.

public getTableField(string $tableName, string $columnName) : ScalarField|null
Parameters
$tableName : string

Name of the table.

$columnName : string

Name of the column.

Tags
throws
SqlQueryException
Return values
ScalarField|null

getTableFields()

Returns fields objects according to the columns of a table.

public getTableFields(mixed $tableName) : array<string|int, ScalarField>
Parameters
$tableName : mixed

The table name.

Tags
inheritDoc
Return values
array<string|int, ScalarField>

An array of objects with columns information.

getTableFullTextFields()

public getTableFullTextFields(mixed $tableName) : mixed
Parameters
$tableName : mixed

getTracker()

Returns an object with information about queries executed.

public getTracker() : null|SqlTracker

or null if no tracking was started.

Return values
null|SqlTracker

getType()

Returns database type.

public getType() : string
Tags
inheritDoc
Return values
string

getVersion()

Returns connected database version.

public getVersion() : array<string|int, mixed>
Tags
inheritDoc
Return values
array<string|int, mixed>

isConnected()

Returns the state of the connection.

public isConnected() : bool
Return values
bool

isDeferred()

Returns true if the connection is deferred.

public isDeferred() : bool
Return values
bool

isIndexExists()

Checks if an index exists.

public isIndexExists(mixed $tableName, array<string|int, mixed> $columns) : bool
Parameters
$tableName : mixed

A table name.

$columns : array<string|int, mixed>

An array of columns in the index.

Tags
inheritDoc
Return values
bool

isPersistent()

Returns true if the connection is persistent.

public isPersistent() : bool
Return values
bool

isQueryExecutingEnabled()

public isQueryExecutingEnabled() : bool
APIYes
Tags
see
disableQueryExecuting
Return values
bool

isTableExists()

Checks if a table exists.

public isTableExists(mixed $tableName) : bool
Parameters
$tableName : mixed

The table name.

Tags
inheritDoc
Return values
bool

isUtf8mb4()

Returns utfmb4 flag for the specific table/column.

public isUtf8mb4([string|null $table = null ][, string|null $column = null ]) : bool
Parameters
$table : string|null = null
$column : string|null = null
Return values
bool

lock()

Sets a global named lock. Currently only Mysql is supported.

public lock(mixed $name[, mixed $timeout = 0 ]) : bool
Parameters
$name : mixed

The lock name.

$timeout : mixed = 0
Tags
inheritDoc
Return values
bool

parseSqlBatch()

Parses the text containing sqls into separate queries.

public parseSqlBatch(string $sqlBatch) : array<string|int, mixed>
Parameters
$sqlBatch : string
Return values
array<string|int, mixed>

query()

Executes a query to the database.

public query(string $sql) : Result
  • query($sql)
  • query($sql, $limit)
  • query($sql, $offset, $limit)
  • query($sql, $binds)
  • query($sql, $binds, $limit)
  • query($sql, $binds, $offset, $limit)
Parameters
$sql : string

Sql query.

Tags
throws
SqlQueryException
Return values
Result

queryExecute()

Executes a query without returning result, i.e. INSERT, UPDATE, DELETE

public queryExecute(string $sql[, array<string|int, mixed>|null $binds = null ]) : void
Parameters
$sql : string

Sql text.

$binds : array<string|int, mixed>|null = null

Binding array.

Tags
throws
SqlQueryException

queryScalar()

Executes a query, fetches a row and returns single field value from the first column of the result.

public queryScalar(string $sql[, array<string|int, mixed>|null $binds = null ]) : string|null
Parameters
$sql : string

Sql text.

$binds : array<string|int, mixed>|null = null

Binding array.

Tags
throws
SqlQueryException
Return values
string|null

renameTable()

Renames the table. Renamed table must exist and new name must not be occupied by any database object.

public renameTable(mixed $currentName, mixed $newName) : void
Parameters
$currentName : mixed

Old name of the table.

$newName : mixed

New name of the table.

Tags
inheritDoc

rollbackTransaction()

Rollbacks started database transaction.

public rollbackTransaction() : void
Tags
inheritDoc

setNodeId()

Sets connection node identifier.

public setNodeId(string $nodeId) : void
Parameters
$nodeId : string

Node identifier.

setTracker()

Sets new sql tracker.

public setTracker([null|SqlTracker $sqlTracker = null ]) : void
Parameters
$sqlTracker : null|SqlTracker = null

New tracker.

startTracker()

Starts collecting information about all queries executed.

public startTracker([bool $reset = false ]) : SqlTracker
Parameters
$reset : bool = false

Clears all previously collected information when set to true.

Return values
SqlTracker

startTransaction()

Starts new database transaction.

public startTransaction() : void
Tags
inheritDoc

stopTracker()

Stops collecting information about all queries executed.

public stopTracker() : void

truncateTable()

Truncates all table data.

public truncateTable(string $tableName) : Result
Parameters
$tableName : string

Name of the table.

Return values
Result

unlock()

Releases a global named lock. Currently only Mysql is supported.

public unlock(mixed $name) : bool
Parameters
$name : mixed

The lock name.

Tags
inheritDoc
Return values
bool

        
On this page

Search results