Bitrix-D7 22.6
 
Загрузка...
Поиск...
Не найдено
Класс Connection
+ Граф наследования:Connection:

Открытые члены

 __construct (array $configuration)
 
 getDbName ()
 
 getHost ()
 
 getLogin ()
 
 getPassword ()
 
 getDatabase ()
 
 disableQueryExecuting ()
 
 enableQueryExecuting ()
 
 isQueryExecutingEnabled ()
 
 getDisabledQueryExecutingDump ()
 
 getSqlHelper ()
 
 connect ()
 
 disconnect ()
 
 isDeferred ()
 
 isPersistent ()
 
 query ($sql)
 
 queryScalar ($sql, array $binds=null)
 
 queryExecute ($sql, array $binds=null)
 
 add ($tableName, array $data, $identity="ID")
 
 addMulti ($tableName, $rows, $identity="ID")
 
 getInsertedId ()
 
 executeSqlBatch ($sqlBatch, $stopOnError=false)
 
 parseSqlBatch ($sqlBatch)
 
 getAffectedRowsCount ()
 
 isTableExists ($tableName)
 
 isIndexExists ($tableName, array $columns)
 
 getIndexName ($tableName, array $columns, $strict=false)
 
 getTableFields ($tableName)
 
 createTable ($tableName, $fields, $primary=array(), $autoincrement=array())
 
 createPrimaryIndex ($tableName, $columnNames)
 
 createIndex ($tableName, $indexName, $columnNames)
 
 getTableField ($tableName, $columnName)
 
 truncateTable ($tableName)
 
 renameTable ($currentName, $newName)
 
 dropColumn ($tableName, $columnName)
 
 dropTable ($tableName)
 
 startTransaction ()
 
 commitTransaction ()
 
 rollbackTransaction ()
 
 lock ($name, $timeout=0)
 
 unlock ($name)
 
 startTracker ($reset=false)
 
 stopTracker ()
 
 getTracker ()
 
 setTracker (Diag\SqlTracker $sqlTracker=null)
 
 getType ()
 
 getVersion ()
 
 clearCaches ()
 
 setNodeId ($nodeId)
 
 getNodeId ()
 
 isUtf8mb4 ($table=null, $column=null)
 
- Открытые члены унаследованные от Connection
 __construct (array $configuration)
 
 connect ()
 
 disconnect ()
 
 getResource ()
 
 isConnected ()
 
 getConfiguration ()
 
 getMaxAllowedPacket ()
 

Открытые атрибуты

const PERSISTENT = 1
 
const DEFERRED = 2
 

Защищенные члены

 createSqlHelper ()
 
 queryInternal ($sql, array $binds=null, Diag\SqlTrackerQuery $trackerQuery=null)
 
 createResult ($result, Diag\SqlTrackerQuery $trackerQuery=null)
 
 getErrorMessage ()
 
 afterConnected ()
 
- Защищенные члены унаследованные от Connection
 connectInternal ()
 
 disconnectInternal ()
 

Защищенные статические члены

static parseQueryFunctionArgs ($args)
 
static findIndex (array $indexes, array $columns, $strict)
 

Защищенные данные

 $sqlHelper
 
 $sqlTracker
 
 $trackSql = false
 
 $version
 
 $versionExpress
 
 $host
 
 $database
 
 $login
 
 $password
 
 $initCommand = 0
 
 $options = 0
 
 $nodeId = 0
 
 $utf8mb4 = array()
 
 $tableColumnsCache = array()
 
 $lastQueryResult
 
 $queryExecutingEnabled = true
 
 $disabledQueryExecutingDump
 
- Защищенные данные унаследованные от Connection
 $resource
 
 $isConnected = false
 
 $configuration
 

Подробное описание

См. определение в файле connection.php строка 16

Конструктор(ы)

◆ __construct()

__construct ( array  $configuration)

$configuration may contain following keys:

  • host
  • database
  • login
  • password
  • initCommand
  • options
Аргументы
array$configurationArray of Name => Value pairs.

Переопределяет метод предка Connection.

См. определение в файле connection.php строка 65

Методы

◆ add()

add (   $tableName,
array  $data,
  $identity = "ID" 
)

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

$identity parameter must be null when table does not have autoincrement column.

Аргументы
string$tableNameName of the table for insertion of new row..
array$dataArray of columnName => Value pairs.
string$identityFor Oracle only.
Возвращает
integer
Исключения
SqlQueryException

См. определение в файле connection.php строка 443

◆ addMulti()

addMulti (   $tableName,
  $rows,
  $identity = "ID" 
)
Аргументы
string$tableName
array$rows
string$identity
Возвращает
int
Исключения
SqlQueryException

См. определение в файле connection.php строка 464

◆ afterConnected()

afterConnected ( )
protected

См. определение в файле connection.php строка 1012

◆ clearCaches()

clearCaches ( )

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

Возвращает
void

См. определение в файле connection.php строка 986

◆ commitTransaction()

commitTransaction ( )
abstract

Commits started database transaction.

Возвращает
void
Исключения
SqlQueryException

◆ connect()

connect ( )

Connects to the database.

Возвращает
void

Переопределяет метод предка Connection.

См. определение в файле connection.php строка 213

◆ createIndex()

createIndex (   $tableName,
  $indexName,
  $columnNames 
)

Creates index on column(s) @api

Аргументы
string$tableNameName of the table.
string$indexNameName of the new index.
string | string[]$columnNamesName of the column or array of column names to be included into the index.
Возвращает
Result
Исключения
SqlQueryException

См. определение в файле connection.php строка 756

◆ createPrimaryIndex()

createPrimaryIndex (   $tableName,
  $columnNames 
)

Creates primary index on column(s) @api

Аргументы
string$tableNameName of the table.
string | string[]$columnNamesName of the column or array of column names to be included into the index.
Возвращает
Result
Исключения
SqlQueryException

См. определение в файле connection.php строка 728

◆ createResult()

createResult (   $result,
Diag\SqlTrackerQuery  $trackerQuery = null 
)
abstractprotected

Returns database depended result of the query.

Аргументы
resource$resultResult of internal query function.
Diag\SqlTrackerQuery | null$trackerQueryDebug collector object.
Возвращает
Result

◆ createSqlHelper()

createSqlHelper ( )
abstractprotected
Возвращает
SqlHelper

◆ createTable()

createTable (   $tableName,
  $fields,
  $primary = array(),
  $autoincrement = array() 
)
abstract
Аргументы
string$tableNameName of the new table.
ScalarField[]$fieldsArray with columns descriptions.
string[]$primaryArray with primary key column names.
string[]$autoincrementWhich columns will be auto incremented ones.
Возвращает
void
Исключения
SqlQueryException

◆ disableQueryExecuting()

disableQueryExecuting ( )

Temporary disables query executing. All queries being collected in disabledQueryExecutingDump

@api

См. также
enableQueryExecuting
getDisabledQueryExecutingDump
Возвращает
void

См. определение в файле connection.php строка 136

◆ disconnect()

disconnect ( )

Disconnects from the database.

Возвращает
void

Переопределяет метод предка Connection.

См. определение в файле connection.php строка 228

◆ dropColumn()

dropColumn (   $tableName,
  $columnName 
)

Drops a column. This column must exists and must be not the part of primary constraint. and must be not the last one in the table.

Аргументы
string$tableNameName of the table to which column will be dropped.
string$columnNameName of the column to be dropped.
Возвращает
void
Исключения
SqlQueryException

См. определение в файле connection.php строка 824

◆ dropTable()

dropTable (   $tableName)
abstract

Drops the table.

Аргументы
string$tableNameName of the table to be dropped.
Возвращает
void
Исключения
SqlQueryException

◆ enableQueryExecuting()

enableQueryExecuting ( )

Enables query executing after it has been temporary disabled

@api

См. также
disableQueryExecuting
Возвращает
void

См. определение в файле connection.php строка 149

◆ executeSqlBatch()

executeSqlBatch (   $sqlBatch,
  $stopOnError = false 
)

Parses the string containing multiple queries and executes the queries one by one. Queries delimiter depends on database type.

См. также
\Bitrix\Main\Db\SqlHelper->getQueryDelimiter
Аргументы
string$sqlBatchString with queries, separated by database-specific delimiters.
bool$stopOnErrorWhether return after the first error.
Возвращает
array Array of errors or empty array on success.

См. определение в файле connection.php строка 532

◆ findIndex()

static findIndex ( array  $indexes,
array  $columns,
  $strict 
)
staticprotected

См. определение в файле connection.php строка 1047

◆ getAffectedRowsCount()

getAffectedRowsCount ( )
abstract

Returns affected rows count from last executed query.

Возвращает
integer

◆ getDatabase()

getDatabase ( )

Returns database name.

Возвращает
string

См. определение в файле connection.php строка 122

◆ getDbName()

getDbName ( )
Возвращает
string

См. определение в файле connection.php строка 82

◆ getDisabledQueryExecutingDump()

getDisabledQueryExecutingDump ( )

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

@api

См. также
disableQueryExecuting
Возвращает
null|string[]

См. определение в файле connection.php строка 173

◆ getErrorMessage()

getErrorMessage ( )
abstractprotected

Returns error message of last failed database operation.

Возвращает
string

◆ getHost()

getHost ( )

Returns database host.

Возвращает
string

См. определение в файле connection.php строка 92

◆ getIndexName()

getIndexName (   $tableName,
array  $columns,
  $strict = false 
)
abstract

Returns the name of an index.

Аргументы
string$tableNameA table name.
array$columnsAn array of columns in the index.
bool$strictThe flag indicating that the columns in the index must exactly match the columns in the $arColumns parameter.
Возвращает
string|null Name of the index or null if the index doesn't exist.

◆ getInsertedId()

getInsertedId ( )
abstract
Возвращает
integer

◆ getLogin()

getLogin ( )

Returns database login.

Возвращает
string

См. определение в файле connection.php строка 102

◆ getNodeId()

getNodeId ( )

Returns connection node identifier.

Возвращает
string|null

См. определение в файле connection.php строка 1007

◆ getPassword()

getPassword ( )

Returns database password.

Возвращает
string

См. определение в файле connection.php строка 112

◆ getSqlHelper()

getSqlHelper ( )

Returns database depended SqlHelper object. Creates new one on the first call per Connection object instance.

Возвращает
SqlHelper

См. определение в файле connection.php строка 196

◆ getTableField()

getTableField (   $tableName,
  $columnName 
)

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

Аргументы
string$tableNameName of the table.
string$columnNameName of the column.
Возвращает
ScalarField | null
Исключения
SqlQueryException

См. определение в файле connection.php строка 785

◆ getTableFields()

getTableFields (   $tableName)
abstract

Returns fields objects according to the columns of a table. Table must exists.

Аргументы
string$tableNameThe table name.
Возвращает
ScalarField[] An array of objects with columns information.
Исключения
SqlQueryException

◆ getTracker()

getTracker ( )

Returns an object with information about queries executed. or null if no tracking was started.

Возвращает
null|Diag\SqlTracker

См. определение в файле connection.php строка 930

◆ getType()

getType ( )
abstract

Returns database type.

  • mysql
  • oracle
  • mssql
Возвращает
string

◆ getVersion()

getVersion ( )
abstract

Returns connected database version. Version presented in array of two elements.

  • First (with index 0) is database version.
  • Second (with index 1) is true when light/express version of database is used.
Возвращает
array
Исключения
SqlQueryException

◆ isDeferred()

isDeferred ( )

Returns true if the connection is deferred.

Возвращает
bool

См. определение в файле connection.php строка 240

◆ isIndexExists()

isIndexExists (   $tableName,
array  $columns 
)
abstract

Checks if an index exists. Actual columns in the index may differ from requested. $columns may present an "prefix" of actual index columns.

Аргументы
string$tableNameA table name.
array$columnsAn array of columns in the index.
Возвращает
boolean
Исключения
SqlQueryException

◆ isPersistent()

isPersistent ( )

Returns true if the connection is persistent.

Возвращает
bool

См. определение в файле connection.php строка 249

◆ isQueryExecutingEnabled()

isQueryExecutingEnabled ( )

@api

См. также
disableQueryExecuting
Возвращает
bool

См. определение в файле connection.php строка 160

◆ isTableExists()

isTableExists (   $tableName)
abstract

Checks if a table exists.

Аргументы
string$tableNameThe table name.
Возвращает
boolean

◆ isUtf8mb4()

isUtf8mb4 (   $table = null,
  $column = null 
)

Returns utfmb4 flag for the specific table/column.

Аргументы
string | null$table
string | null$column
Возвращает
bool

См. определение в файле connection.php строка 1027

◆ lock()

lock (   $name,
  $timeout = 0 
)

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

Аргументы
string$nameThe lock name.
int$timeout
Возвращает
bool

См. определение в файле connection.php строка 877

◆ parseQueryFunctionArgs()

static parseQueryFunctionArgs (   $args)
staticprotected

Helper function for parameters handling.

Аргументы
mixed$argsVariable list of parameters.
Возвращает
array
Исключения
ArgumentNullException

См. определение в файле connection.php строка 387

◆ parseSqlBatch()

parseSqlBatch (   $sqlBatch)

Parses the text containing sqls into separate queries.

Аргументы
string$sqlBatch
Возвращает
array

См. определение в файле connection.php строка 560

◆ query()

query (   $sql)

Executes a query to the database.

  • query($sql)
  • query($sql, $limit)
  • query($sql, $offset, $limit)
  • query($sql, $binds)
  • query($sql, $binds, $limit)
  • query($sql, $binds, $offset, $limit)
Аргументы
string$sqlSql query.
array$bindsArray of binds.
int$offsetOffset the of the first row to return, starting from 0.
int$limitLimit rows count.
Возвращает
Result
Исключения
SqlQueryException

См. определение в файле connection.php строка 302

◆ queryExecute()

queryExecute (   $sql,
array  $binds = null 
)

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

Аргументы
string$sqlSql text.
array | null$bindsBinding array.
Возвращает
void
Исключения
SqlQueryException

См. определение в файле connection.php строка 374

◆ queryInternal()

queryInternal (   $sql,
array  $binds = null,
Diag\SqlTrackerQuery  $trackerQuery = null 
)
abstractprotected

Executes a query against connected database. Rises SqlQueryException on any database error.

When object $trackerQuery passed then calls its startQuery and finishQuery methods before and after query execution.

Аргументы
string$sqlSql query.
array | null$bindsArray of binds.
Diag\SqlTrackerQuery | null$trackerQueryDebug collector object.
Возвращает
resource
Исключения
SqlQueryException

◆ queryScalar()

queryScalar (   $sql,
array  $binds = null 
)

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

Аргументы
string$sqlSql text.
array | null$bindsBinding array.
Возвращает
string|null
Исключения
SqlQueryException

См. определение в файле connection.php строка 353

◆ renameTable()

renameTable (   $currentName,
  $newName 
)
abstract

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

Аргументы
string$currentNameOld name of the table.
string$newNameNew name of the table.
Возвращает
void
Исключения
SqlQueryException

◆ rollbackTransaction()

rollbackTransaction ( )
abstract

Rollbacks started database transaction.

Возвращает
void
Исключения
SqlQueryException

◆ setNodeId()

setNodeId (   $nodeId)

Sets connection node identifier.

Аргументы
string$nodeIdNode identifier.
Возвращает
void

См. определение в файле connection.php строка 997

◆ setTracker()

setTracker ( Diag\SqlTracker  $sqlTracker = null)

Sets new sql tracker.

Аргументы
null | Diag\SqlTracker$sqlTrackerNew tracker.
Возвращает
void

См. определение в файле connection.php строка 942

◆ startTracker()

startTracker (   $reset = false)

Starts collecting information about all queries executed.

Аргументы
boolean$resetClears all previously collected information when set to true.
Возвращает
Diag\SqlTracker

См. определение в файле connection.php строка 903

◆ startTransaction()

startTransaction ( )
abstract

Starts new database transaction.

Возвращает
void
Исключения
SqlQueryException

◆ stopTracker()

stopTracker ( )

Stops collecting information about all queries executed.

Возвращает
void

См. определение в файле connection.php строка 919

◆ truncateTable()

truncateTable (   $tableName)

Truncates all table data.

Аргументы
string$tableNameName of the table.
Возвращает
Result

См. определение в файле connection.php строка 798

◆ unlock()

unlock (   $name)

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

Аргументы
string$nameThe lock name.
Возвращает
bool

См. определение в файле connection.php строка 887

Данные класса

◆ $database

$database
protected

См. определение в файле connection.php строка 29

◆ $disabledQueryExecutingDump

$disabledQueryExecutingDump
protected

См. определение в файле connection.php строка 47

◆ $host

$host
protected

См. определение в файле connection.php строка 28

◆ $initCommand

$initCommand = 0
protected

См. определение в файле connection.php строка 32

◆ $lastQueryResult

$lastQueryResult
protected

См. определение в файле connection.php строка 38

◆ $login

$login
protected

См. определение в файле connection.php строка 30

◆ $nodeId

$nodeId = 0
protected

См. определение в файле connection.php строка 34

◆ $options

$options = 0
protected

См. определение в файле connection.php строка 33

◆ $password

$password
protected

См. определение в файле connection.php строка 31

◆ $queryExecutingEnabled

$queryExecutingEnabled = true
protected

См. определение в файле connection.php строка 44

◆ $sqlHelper

$sqlHelper
protected

См. определение в файле connection.php строка 19

◆ $sqlTracker

$sqlTracker
protected

См. определение в файле connection.php строка 22

◆ $tableColumnsCache

$tableColumnsCache = array()
protected

См. определение в файле connection.php строка 37

◆ $trackSql

$trackSql = false
protected

См. определение в файле connection.php строка 23

◆ $utf8mb4

$utf8mb4 = array()
protected

См. определение в файле connection.php строка 35

◆ $version

$version
protected

См. определение в файле connection.php строка 25

◆ $versionExpress

$versionExpress
protected

См. определение в файле connection.php строка 26

◆ DEFERRED

const DEFERRED = 2

См. определение в файле connection.php строка 50

◆ PERSISTENT

const PERSISTENT = 1

См. определение в файле connection.php строка 49