1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
Класс Connection
Граф наследования: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=[], $autoincrement=[])
 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 ()
 getErrorMessage ()
 getErrorCode ()
 clearCaches ()
 setNodeId ($nodeId)
 getNodeId ()
 isUtf8mb4 ($table=null, $column=null)
 createQueryException ($code=0, $databaseMessage='', $query='')
Открытые члены унаследованные от Connection
 getResource ()
 isConnected ()
 getConfiguration ()
 getMaxAllowedPacket ()

Поля данных

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

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

 createSqlHelper ()
 queryInternal ($sql, array $binds=null, Diag\SqlTrackerQuery $trackerQuery=null)
 createResult ($result, Diag\SqlTrackerQuery $trackerQuery=null)
 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 = []
 $tableColumnsCache = []
 $lastQueryResult
 $queryExecutingEnabled = true
 $disabledQueryExecutingDump
Защищенные данные унаследованные от Connection
 $resource
 $isConnected = false
 $configuration

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

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

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

◆ __construct()

__construct ( array $configuration)

$configuration may contain following keys:

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

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

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

Методы

◆ 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 строка 450

◆ addMulti()

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

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

◆ afterConnected()

afterConnected ( )
protected

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

◆ clearCaches()

clearCaches ( )

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

Возвращает
void

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

◆ commitTransaction()

commitTransaction ( )
abstract

Commits started database transaction.

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

◆ connect()

connect ( )

Connects to the database.

Возвращает
void

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

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

◆ createIndex()

createIndex ( $tableName,
$indexName,
$columnNames )

Creates index on column(s)

Аргументы
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 | false
Исключения
SqlQueryException@api

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

◆ createPrimaryIndex()

createPrimaryIndex ( $tableName,
$columnNames )

Creates primary index on column(s)

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

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

◆ createQueryException()

createQueryException ( $code = 0,
$databaseMessage = '',
$query = '' )

Creates an exception by the error code.

Аргументы
int | string$code
string$databaseMessage
string$query

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

◆ 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

◆ createTable()

createTable ( $tableName,
$fields,
$primary = [],
$autoincrement = [] )
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

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

@api

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

◆ disconnect()

disconnect ( )

Disconnects from the database.

Возвращает
void

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

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

◆ dropColumn()

dropColumn ( $tableName,
$columnName )

Drops a column. This column must exist 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 строка 858

◆ 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

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

@api

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

◆ executeSqlBatch()

executeSqlBatch ( $sqlBatch,
$stopOnError = false )

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

Аргументы
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.
См. также
SqlHelper->getQueryDelimiter

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

◆ findIndex()

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

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

◆ getAffectedRowsCount()

getAffectedRowsCount ( )
abstract

Returns affected rows count from last executed query.

Возвращает
integer

◆ getDatabase()

getDatabase ( )

Returns database name.

Возвращает
string

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

◆ getDbName()

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

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

◆ getDisabledQueryExecutingDump()

getDisabledQueryExecutingDump ( )

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

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

@api

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

◆ getErrorCode()

getErrorCode ( )

Returns the error code of the last failed database operation.

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

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

◆ getErrorMessage()

getErrorMessage ( )
abstract

Returns error message of last failed database operation.

Возвращает
string

◆ getHost()

getHost ( )

Returns database host.

Возвращает
string

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

◆ 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 строка 100

◆ getNodeId()

getNodeId ( )

Returns connection node identifier.

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

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

◆ getPassword()

getPassword ( )

Returns database password.

Возвращает
string

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

◆ getSqlHelper()

getSqlHelper ( )

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

Возвращает
MysqliSqlHelper | PgsqlSqlHelper

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

◆ 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 строка 819

◆ getTableFields()

getTableFields ( $tableName)
abstract

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

Аргументы
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 строка 968

◆ 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 строка 237

◆ isIndexExists()

isIndexExists ( $tableName,
array $columns )
abstract

Checks if an index exists. Actual columns in the index may differ from requested. $columns may present a "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 строка 246

◆ isQueryExecutingEnabled()

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

@api

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

◆ 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 строка 1075

◆ lock()

lock ( $name,
$timeout = 0 )

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

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

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

◆ parseQueryFunctionArgs()

parseQueryFunctionArgs ( $args)
staticprotected

Helper function for parameters handling.

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

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

◆ parseSqlBatch()

parseSqlBatch ( $sqlBatch)

Parses the text containing sqls into separate queries.

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

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

◆ 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 строка 299

◆ 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 строка 371

◆ 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| DuplicateEntryException

◆ 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 строка 350

◆ renameTable()

renameTable ( $currentName,
$newName )
abstract

Renames the table. Renamed table must exist 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 строка 1045

◆ setTracker()

setTracker ( Diag\SqlTracker $sqlTracker = null)

Sets new sql tracker.

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

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

◆ 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 строка 937

◆ startTransaction()

startTransaction ( )
abstract

Starts new database transaction.

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

◆ stopTracker()

stopTracker ( )

Stops collecting information about all queries executed.

Возвращает
void

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

◆ truncateTable()

truncateTable ( $tableName)

Truncates all table data.

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

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

◆ unlock()

unlock ( $name)

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

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

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

Поля

◆ $database

$database
protected

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

◆ $disabledQueryExecutingDump

$disabledQueryExecutingDump
protected

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

◆ $host

$host
protected

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

◆ $initCommand

$initCommand = 0
protected

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

◆ $lastQueryResult

$lastQueryResult
protected

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

◆ $login

$login
protected

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

◆ $nodeId

$nodeId = 0
protected

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

◆ $options

$options = 0
protected

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

◆ $password

$password
protected

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

◆ $queryExecutingEnabled

$queryExecutingEnabled = true
protected

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

◆ $sqlHelper

$sqlHelper
protected

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

◆ $sqlTracker

$sqlTracker
protected

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

◆ $tableColumnsCache

$tableColumnsCache = []
protected

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

◆ $trackSql

$trackSql = false
protected

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

◆ $utf8mb4

$utf8mb4 = []
protected

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

◆ $version

$version
protected

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

◆ $versionExpress

$versionExpress
protected

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

◆ DEFERRED

const DEFERRED = 2

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

◆ INDEX_FULLTEXT

const INDEX_FULLTEXT = 'FULLTEXT'

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

◆ INDEX_SPATIAL

const INDEX_SPATIAL = 'SPATIAL'

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

◆ INDEX_UNIQUE

const INDEX_UNIQUE = 'UNIQUE'

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

◆ PERSISTENT

const PERSISTENT = 1

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


Объявления и описания членов класса находятся в файле: