idx
int64
0
241k
question
stringlengths
64
6.21k
target
stringlengths
5
803
3,200
private function getDatabasePlatformVersion ( ) { if ( ! $ this -> _driver instanceof VersionAwarePlatformDriver ) { return null ; } if ( isset ( $ this -> params [ 'serverVersion' ] ) ) { return $ this -> params [ 'serverVersion' ] ; } if ( $ this -> _conn === null ) { try { $ this -> connect ( ) ; } catch ( Throwable...
Returns the version of the related platform if applicable .
3,201
private function getServerVersion ( ) { $ connection = $ this -> getWrappedConnection ( ) ; if ( $ connection instanceof ServerInfoAwareConnection && ! $ connection -> requiresQueryForServerVersion ( ) ) { return $ connection -> getServerVersion ( ) ; } return null ; }
Returns the database server version if the underlying driver supports it .
3,202
public function setAutoCommit ( $ autoCommit ) { $ autoCommit = ( bool ) $ autoCommit ; if ( $ autoCommit === $ this -> autoCommit ) { return ; } $ this -> autoCommit = $ autoCommit ; if ( $ this -> isConnected !== true || $ this -> transactionNestingLevel === 0 ) { return ; } $ this -> commitAll ( ) ; }
Sets auto - commit mode for this connection .
3,203
public function fetchAssoc ( $ statement , array $ params = [ ] , array $ types = [ ] ) { return $ this -> executeQuery ( $ statement , $ params , $ types ) -> fetch ( FetchMode :: ASSOCIATIVE ) ; }
Prepares and executes an SQL query and returns the first row of the result as an associative array .
3,204
public function fetchArray ( $ statement , array $ params = [ ] , array $ types = [ ] ) { return $ this -> executeQuery ( $ statement , $ params , $ types ) -> fetch ( FetchMode :: NUMERIC ) ; }
Prepares and executes an SQL query and returns the first row of the result as a numerically indexed array .
3,205
private function addIdentifierCondition ( array $ identifier , array & $ columns , array & $ values , array & $ conditions ) : void { $ platform = $ this -> getDatabasePlatform ( ) ; foreach ( $ identifier as $ columnName => $ value ) { if ( $ value === null ) { $ conditions [ ] = $ platform -> getIsNullExpression ( $ ...
Adds identifier condition to the query components
3,206
public function delete ( $ tableExpression , array $ identifier , array $ types = [ ] ) { if ( empty ( $ identifier ) ) { throw InvalidArgumentException :: fromEmptyCriteria ( ) ; } $ columns = $ values = $ conditions = [ ] ; $ this -> addIdentifierCondition ( $ identifier , $ columns , $ values , $ conditions ) ; retu...
Executes an SQL DELETE statement on a table .
3,207
public function setTransactionIsolation ( $ level ) { $ this -> transactionIsolationLevel = $ level ; return $ this -> executeUpdate ( $ this -> getDatabasePlatform ( ) -> getSetTransactionIsolationSQL ( $ level ) ) ; }
Sets the transaction isolation level .
3,208
public function getTransactionIsolation ( ) { if ( $ this -> transactionIsolationLevel === null ) { $ this -> transactionIsolationLevel = $ this -> getDatabasePlatform ( ) -> getDefaultTransactionIsolationLevel ( ) ; } return $ this -> transactionIsolationLevel ; }
Gets the currently active transaction isolation level .
3,209
public function update ( $ tableExpression , array $ data , array $ identifier , array $ types = [ ] ) { $ columns = $ values = $ conditions = $ set = [ ] ; foreach ( $ data as $ columnName => $ value ) { $ columns [ ] = $ columnName ; $ values [ ] = $ value ; $ set [ ] = $ columnName . ' = ?' ; } $ this -> addIdentifi...
Executes an SQL UPDATE statement on a table .
3,210
private function extractTypeValues ( array $ columnList , array $ types ) { $ typeValues = [ ] ; foreach ( $ columnList as $ columnIndex => $ columnName ) { $ typeValues [ ] = $ types [ $ columnName ] ?? ParameterType :: STRING ; } return $ typeValues ; }
Extract ordered type list from an ordered column list and type map .
3,211
public function fetchAll ( $ sql , array $ params = [ ] , $ types = [ ] ) { return $ this -> executeQuery ( $ sql , $ params , $ types ) -> fetchAll ( ) ; }
Prepares and executes an SQL query and returns the result as an associative array .
3,212
public function executeQuery ( $ query , array $ params = [ ] , $ types = [ ] , ? QueryCacheProfile $ qcp = null ) { if ( $ qcp !== null ) { return $ this -> executeCacheQuery ( $ query , $ params , $ types , $ qcp ) ; } $ connection = $ this -> getWrappedConnection ( ) ; $ logger = $ this -> _config -> getSQLLogger ( ...
Executes an optionally parametrized SQL query .
3,213
public function executeCacheQuery ( $ query , $ params , $ types , QueryCacheProfile $ qcp ) { $ resultCache = $ qcp -> getResultCacheDriver ( ) ?? $ this -> _config -> getResultCacheImpl ( ) ; if ( $ resultCache === null ) { throw CacheException :: noResultDriverConfigured ( ) ; } $ connectionParams = $ this -> getPar...
Executes a caching query .
3,214
public function exec ( $ statement ) { $ connection = $ this -> getWrappedConnection ( ) ; $ logger = $ this -> _config -> getSQLLogger ( ) ; if ( $ logger ) { $ logger -> startQuery ( $ statement ) ; } try { $ result = $ connection -> exec ( $ statement ) ; } catch ( Throwable $ ex ) { throw DBALException :: driverExc...
Executes an SQL statement and return the number of affected rows .
3,215
public function setNestTransactionsWithSavepoints ( $ nestTransactionsWithSavepoints ) { if ( $ this -> transactionNestingLevel > 0 ) { throw ConnectionException :: mayNotAlterNestedTransactionWithSavepointsInTransaction ( ) ; } if ( ! $ this -> getDatabasePlatform ( ) -> supportsSavepoints ( ) ) { throw ConnectionExce...
Sets if nested transactions should use savepoints .
3,216
private function commitAll ( ) { while ( $ this -> transactionNestingLevel !== 0 ) { if ( $ this -> autoCommit === false && $ this -> transactionNestingLevel === 1 ) { $ this -> commit ( ) ; return ; } $ this -> commit ( ) ; } }
Commits all current nesting transactions .
3,217
public function rollBack ( ) { if ( $ this -> transactionNestingLevel === 0 ) { throw ConnectionException :: noActiveTransaction ( ) ; } $ connection = $ this -> getWrappedConnection ( ) ; $ logger = $ this -> _config -> getSQLLogger ( ) ; if ( $ this -> transactionNestingLevel === 1 ) { if ( $ logger ) { $ logger -> s...
Cancels any database changes done during the current transaction .
3,218
public function createSavepoint ( $ savepoint ) { if ( ! $ this -> getDatabasePlatform ( ) -> supportsSavepoints ( ) ) { throw ConnectionException :: savepointsNotSupported ( ) ; } $ this -> getWrappedConnection ( ) -> exec ( $ this -> platform -> createSavePoint ( $ savepoint ) ) ; }
Creates a new savepoint .
3,219
public function releaseSavepoint ( $ savepoint ) { if ( ! $ this -> getDatabasePlatform ( ) -> supportsSavepoints ( ) ) { throw ConnectionException :: savepointsNotSupported ( ) ; } if ( ! $ this -> platform -> supportsReleaseSavepoints ( ) ) { return ; } $ this -> getWrappedConnection ( ) -> exec ( $ this -> platform ...
Releases the given savepoint .
3,220
public function rollbackSavepoint ( $ savepoint ) { if ( ! $ this -> getDatabasePlatform ( ) -> supportsSavepoints ( ) ) { throw ConnectionException :: savepointsNotSupported ( ) ; } $ this -> getWrappedConnection ( ) -> exec ( $ this -> platform -> rollbackSavePoint ( $ savepoint ) ) ; }
Rolls back to the given savepoint .
3,221
public function getSchemaManager ( ) { if ( $ this -> _schemaManager === null ) { $ this -> _schemaManager = $ this -> _driver -> getSchemaManager ( $ this ) ; } return $ this -> _schemaManager ; }
Gets the SchemaManager that can be used to inspect or change the database schema through the connection .
3,222
public function convertToDatabaseValue ( $ value , $ type ) { return Type :: getType ( $ type ) -> convertToDatabaseValue ( $ value , $ this -> getDatabasePlatform ( ) ) ; }
Converts a given value to its database representation according to the conversion rules of a specific DBAL mapping type .
3,223
private function _bindTypedValues ( $ stmt , array $ params , array $ types ) { if ( is_int ( key ( $ params ) ) ) { $ typeOffset = array_key_exists ( 0 , $ types ) ? - 1 : 0 ; $ bindIndex = 1 ; foreach ( $ params as $ value ) { $ typeIndex = $ bindIndex + $ typeOffset ; if ( isset ( $ types [ $ typeIndex ] ) ) { $ typ...
Binds a set of parameters some or all of which are typed with a PDO binding type or DBAL mapping type to a given statement .
3,224
private function getBindingInfo ( $ value , $ type ) { if ( is_string ( $ type ) ) { $ type = Type :: getType ( $ type ) ; } if ( $ type instanceof Type ) { $ value = $ type -> convertToDatabaseValue ( $ value , $ this -> getDatabasePlatform ( ) ) ; $ bindingType = $ type -> getBindingType ( ) ; } else { $ bindingType ...
Gets the binding type of a given type . The given type can be a PDO or DBAL mapping type .
3,225
public function resolveParams ( array $ params , array $ types ) { $ resolvedParams = [ ] ; if ( is_int ( key ( $ params ) ) ) { $ typeOffset = array_key_exists ( 0 , $ types ) ? - 1 : 0 ; $ bindIndex = 1 ; foreach ( $ params as $ value ) { $ typeIndex = $ bindIndex + $ typeOffset ; if ( isset ( $ types [ $ typeIndex ]...
Resolves the parameters to a format which can be displayed .
3,226
private function gatherAlterColumnSQL ( Identifier $ table , ColumnDiff $ columnDiff , array & $ sql , array & $ queryParts ) { $ alterColumnClauses = $ this -> getAlterColumnClausesSQL ( $ columnDiff ) ; if ( empty ( $ alterColumnClauses ) ) { return ; } if ( count ( $ alterColumnClauses ) === 1 ) { $ queryParts [ ] =...
Gathers the table alteration SQL for a given column diff .
3,227
private function getAlterColumnClausesSQL ( ColumnDiff $ columnDiff ) { $ column = $ columnDiff -> column -> toArray ( ) ; $ alterClause = 'ALTER COLUMN ' . $ columnDiff -> column -> getQuotedName ( $ this ) ; if ( $ column [ 'columnDefinition' ] ) { return [ $ alterClause . ' ' . $ column [ 'columnDefinition' ] ] ; } ...
Returns the ALTER COLUMN SQL clauses for altering a column described by the given column diff .
3,228
public function add ( $ part ) { if ( empty ( $ part ) ) { return $ this ; } if ( $ part instanceof self && count ( $ part ) === 0 ) { return $ this ; } $ this -> parts [ ] = $ part ; return $ this ; }
Adds an expression to composite expression .
3,229
private function initializeAllDoctrineTypeMappings ( ) { $ this -> initializeDoctrineTypeMappings ( ) ; foreach ( Type :: getTypesMap ( ) as $ typeName => $ className ) { foreach ( Type :: getType ( $ typeName ) -> getMappedDatabaseTypes ( $ this ) as $ dbType ) { $ this -> doctrineTypeMapping [ $ dbType ] = $ typeName...
Initializes Doctrine Type Mappings with the platform defaults and with all additional type mappings .
3,230
public function registerDoctrineTypeMapping ( $ dbType , $ doctrineType ) { if ( $ this -> doctrineTypeMapping === null ) { $ this -> initializeAllDoctrineTypeMappings ( ) ; } if ( ! Types \ Type :: hasType ( $ doctrineType ) ) { throw DBALException :: typeNotFound ( $ doctrineType ) ; } $ dbType = strtolower ( $ dbTyp...
Registers a doctrine type to be used in conjunction with a column type of this platform .
3,231
public function getDoctrineTypeMapping ( $ dbType ) { if ( $ this -> doctrineTypeMapping === null ) { $ this -> initializeAllDoctrineTypeMappings ( ) ; } $ dbType = strtolower ( $ dbType ) ; if ( ! isset ( $ this -> doctrineTypeMapping [ $ dbType ] ) ) { throw new DBALException ( 'Unknown database type ' . $ dbType . '...
Gets the Doctrine type that is mapped for the given database column type .
3,232
public function hasDoctrineTypeMappingFor ( $ dbType ) { if ( $ this -> doctrineTypeMapping === null ) { $ this -> initializeAllDoctrineTypeMappings ( ) ; } $ dbType = strtolower ( $ dbType ) ; return isset ( $ this -> doctrineTypeMapping [ $ dbType ] ) ; }
Checks if a database type is currently supported by this platform .
3,233
public function isCommentedDoctrineType ( Type $ doctrineType ) { if ( $ this -> doctrineTypeComments === null ) { $ this -> initializeCommentedDoctrineTypes ( ) ; } assert ( is_array ( $ this -> doctrineTypeComments ) ) ; return in_array ( $ doctrineType -> getName ( ) , $ this -> doctrineTypeComments ) ; }
Is it necessary for the platform to add a parsable type comment to allow reverse engineering the given type?
3,234
public function markDoctrineTypeCommented ( $ doctrineType ) { if ( $ this -> doctrineTypeComments === null ) { $ this -> initializeCommentedDoctrineTypes ( ) ; } assert ( is_array ( $ this -> doctrineTypeComments ) ) ; $ this -> doctrineTypeComments [ ] = $ doctrineType instanceof Type ? $ doctrineType -> getName ( ) ...
Marks this type as to be commented in ALTER TABLE and CREATE TABLE statements .
3,235
public function getTrimExpression ( $ str , $ mode = TrimMode :: UNSPECIFIED , $ char = false ) { $ expression = '' ; switch ( $ mode ) { case TrimMode :: LEADING : $ expression = 'LEADING ' ; break ; case TrimMode :: TRAILING : $ expression = 'TRAILING ' ; break ; case TrimMode :: BOTH : $ expression = 'BOTH ' ; break...
Returns the SQL snippet to trim a string .
3,236
public function getDropTableSQL ( $ table ) { $ tableArg = $ table ; if ( $ table instanceof Table ) { $ table = $ table -> getQuotedName ( $ this ) ; } if ( ! is_string ( $ table ) ) { throw new InvalidArgumentException ( 'getDropTableSQL() expects $table parameter to be string or \Doctrine\DBAL\Schema\Table.' ) ; } i...
Returns the SQL snippet to drop an existing table .
3,237
public function getDropIndexSQL ( $ index , $ table = null ) { if ( $ index instanceof Index ) { $ index = $ index -> getQuotedName ( $ this ) ; } elseif ( ! is_string ( $ index ) ) { throw new InvalidArgumentException ( 'AbstractPlatform::getDropIndexSQL() expects $index parameter to be string or \Doctrine\DBAL\Schema...
Returns the SQL to drop an index from a table .
3,238
public function getDropConstraintSQL ( $ constraint , $ table ) { if ( ! $ constraint instanceof Constraint ) { $ constraint = new Identifier ( $ constraint ) ; } if ( ! $ table instanceof Table ) { $ table = new Identifier ( $ table ) ; } $ constraint = $ constraint -> getQuotedName ( $ this ) ; $ table = $ table -> g...
Returns the SQL to drop a constraint .
3,239
public function getDropForeignKeySQL ( $ foreignKey , $ table ) { if ( ! $ foreignKey instanceof ForeignKeyConstraint ) { $ foreignKey = new Identifier ( $ foreignKey ) ; } if ( ! $ table instanceof Table ) { $ table = new Identifier ( $ table ) ; } $ foreignKey = $ foreignKey -> getQuotedName ( $ this ) ; $ table = $ ...
Returns the SQL to drop a foreign key .
3,240
public function getInlineColumnCommentSQL ( $ comment ) { if ( ! $ this -> supportsInlineColumnComments ( ) ) { throw DBALException :: notSupported ( __METHOD__ ) ; } return 'COMMENT ' . $ this -> quoteStringLiteral ( $ comment ) ; }
Returns the SQL to create inline comment on a column .
3,241
protected function _getCreateTableSQL ( $ tableName , array $ columns , array $ options = [ ] ) { $ columnListSql = $ this -> getColumnDeclarationListSQL ( $ columns ) ; if ( isset ( $ options [ 'uniqueConstraints' ] ) && ! empty ( $ options [ 'uniqueConstraints' ] ) ) { foreach ( $ options [ 'uniqueConstraints' ] as $...
Returns the SQL used to create a table .
3,242
public function getCreateConstraintSQL ( Constraint $ constraint , $ table ) { if ( $ table instanceof Table ) { $ table = $ table -> getQuotedName ( $ this ) ; } $ query = 'ALTER TABLE ' . $ table . ' ADD CONSTRAINT ' . $ constraint -> getQuotedName ( $ this ) ; $ columnList = '(' . implode ( ', ' , $ constraint -> ge...
Returns the SQL to create a constraint on a table on this platform .
3,243
public function getCreateIndexSQL ( Index $ index , $ table ) { if ( $ table instanceof Table ) { $ table = $ table -> getQuotedName ( $ this ) ; } $ name = $ index -> getQuotedName ( $ this ) ; $ columns = $ index -> getColumns ( ) ; if ( count ( $ columns ) === 0 ) { throw new InvalidArgumentException ( "Incomplete d...
Returns the SQL to create an index on a table on this platform .
3,244
public function quoteIdentifier ( $ str ) { if ( strpos ( $ str , '.' ) !== false ) { $ parts = array_map ( [ $ this , 'quoteSingleIdentifier' ] , explode ( '.' , $ str ) ) ; return implode ( '.' , $ parts ) ; } return $ this -> quoteSingleIdentifier ( $ str ) ; }
Quotes a string so that it can be safely used as a table or column name even if it is a reserved word of the platform . This also detects identifier chains separated by dot and quotes them independently .
3,245
public function getCreateForeignKeySQL ( ForeignKeyConstraint $ foreignKey , $ table ) { if ( $ table instanceof Table ) { $ table = $ table -> getQuotedName ( $ this ) ; } return 'ALTER TABLE ' . $ table . ' ADD ' . $ this -> getForeignKeyDeclarationSQL ( $ foreignKey ) ; }
Returns the SQL to create a new foreign key .
3,246
protected function getRenameIndexSQL ( $ oldIndexName , Index $ index , $ tableName ) { return [ $ this -> getDropIndexSQL ( $ oldIndexName , $ tableName ) , $ this -> getCreateIndexSQL ( $ index , $ tableName ) , ] ; }
Returns the SQL for renaming an index on a table .
3,247
protected function _getAlterTableIndexForeignKeySQL ( TableDiff $ diff ) { return array_merge ( $ this -> getPreAlterTableIndexForeignKeySQL ( $ diff ) , $ this -> getPostAlterTableIndexForeignKeySQL ( $ diff ) ) ; }
Common code for alter table statement generation that updates the changed Index and Foreign Key definitions .
3,248
public function getColumnDeclarationListSQL ( array $ fields ) { $ queryFields = [ ] ; foreach ( $ fields as $ fieldName => $ field ) { $ queryFields [ ] = $ this -> getColumnDeclarationSQL ( $ fieldName , $ field ) ; } return implode ( ', ' , $ queryFields ) ; }
Gets declaration of a number of fields in bulk .
3,249
public function getColumnDeclarationSQL ( $ name , array $ field ) { if ( isset ( $ field [ 'columnDefinition' ] ) ) { $ columnDef = $ this -> getCustomTypeDeclarationSQL ( $ field ) ; } else { $ default = $ this -> getDefaultValueDeclarationSQL ( $ field ) ; $ charset = isset ( $ field [ 'charset' ] ) && $ field [ 'ch...
Obtains DBMS specific SQL code portion needed to declare a generic type field to be used in statements like CREATE TABLE .
3,250
public function getDecimalTypeDeclarationSQL ( array $ columnDef ) { $ columnDef [ 'precision' ] = ! isset ( $ columnDef [ 'precision' ] ) || empty ( $ columnDef [ 'precision' ] ) ? 10 : $ columnDef [ 'precision' ] ; $ columnDef [ 'scale' ] = ! isset ( $ columnDef [ 'scale' ] ) || empty ( $ columnDef [ 'scale' ] ) ? 0 ...
Returns the SQL snippet that declares a floating point column of arbitrary precision .
3,251
public function getDefaultValueDeclarationSQL ( $ field ) { if ( ! isset ( $ field [ 'default' ] ) ) { return empty ( $ field [ 'notnull' ] ) ? ' DEFAULT NULL' : '' ; } $ default = $ field [ 'default' ] ; if ( ! isset ( $ field [ 'type' ] ) ) { return " DEFAULT '" . $ default . "'" ; } $ type = $ field [ 'type' ] ; if ...
Obtains DBMS specific SQL code portion needed to set a default value declaration to be used in statements like CREATE TABLE .
3,252
public function getCheckDeclarationSQL ( array $ definition ) { $ constraints = [ ] ; foreach ( $ definition as $ field => $ def ) { if ( is_string ( $ def ) ) { $ constraints [ ] = 'CHECK (' . $ def . ')' ; } else { if ( isset ( $ def [ 'min' ] ) ) { $ constraints [ ] = 'CHECK (' . $ field . ' >= ' . $ def [ 'min' ] ....
Obtains DBMS specific SQL code portion needed to set a CHECK constraint declaration to be used in statements like CREATE TABLE .
3,253
public function getUniqueConstraintDeclarationSQL ( $ name , Index $ index ) { $ columns = $ index -> getColumns ( ) ; $ name = new Identifier ( $ name ) ; if ( count ( $ columns ) === 0 ) { throw new InvalidArgumentException ( "Incomplete definition. 'columns' required." ) ; } return 'CONSTRAINT ' . $ name -> getQuote...
Obtains DBMS specific SQL code portion needed to set a unique constraint declaration to be used in statements like CREATE TABLE .
3,254
public function getIndexFieldDeclarationListSQL ( $ columnsOrIndex ) : string { if ( $ columnsOrIndex instanceof Index ) { return implode ( ', ' , $ columnsOrIndex -> getQuotedColumns ( $ this ) ) ; } if ( ! is_array ( $ columnsOrIndex ) ) { throw new InvalidArgumentException ( 'Fields argument should be an Index or ar...
Obtains DBMS specific SQL code portion needed to set an index declaration to be used in statements like CREATE TABLE .
3,255
public function getForeignKeyDeclarationSQL ( ForeignKeyConstraint $ foreignKey ) { $ sql = $ this -> getForeignKeyBaseDeclarationSQL ( $ foreignKey ) ; $ sql .= $ this -> getAdvancedForeignKeyOptionsSQL ( $ foreignKey ) ; return $ sql ; }
Obtain DBMS specific SQL code portion needed to set the FOREIGN KEY constraint of a field declaration to be used in statements like CREATE TABLE .
3,256
public function getAdvancedForeignKeyOptionsSQL ( ForeignKeyConstraint $ foreignKey ) { $ query = '' ; if ( $ this -> supportsForeignKeyOnUpdate ( ) && $ foreignKey -> hasOption ( 'onUpdate' ) ) { $ query .= ' ON UPDATE ' . $ this -> getForeignKeyReferentialActionSQL ( $ foreignKey -> getOption ( 'onUpdate' ) ) ; } if ...
Returns the FOREIGN KEY query section dealing with non - standard options as MATCH INITIALLY DEFERRED ON UPDATE ...
3,257
public function getForeignKeyBaseDeclarationSQL ( ForeignKeyConstraint $ foreignKey ) { $ sql = '' ; if ( strlen ( $ foreignKey -> getName ( ) ) ) { $ sql .= 'CONSTRAINT ' . $ foreignKey -> getQuotedName ( $ this ) . ' ' ; } $ sql .= 'FOREIGN KEY (' ; if ( count ( $ foreignKey -> getLocalColumns ( ) ) === 0 ) { throw n...
Obtains DBMS specific SQL code portion needed to set the FOREIGN KEY constraint of a field declaration to be used in statements like CREATE TABLE .
3,258
public function convertBooleans ( $ item ) { if ( is_array ( $ item ) ) { foreach ( $ item as $ k => $ value ) { if ( ! is_bool ( $ value ) ) { continue ; } $ item [ $ k ] = ( int ) $ value ; } } elseif ( is_bool ( $ item ) ) { $ item = ( int ) $ item ; } return $ item ; }
Some platforms need the boolean values to be converted .
3,259
final public function modifyLimitQuery ( $ query , $ limit , $ offset = null ) { if ( $ limit !== null ) { $ limit = ( int ) $ limit ; } $ offset = ( int ) $ offset ; if ( $ offset < 0 ) { throw new DBALException ( sprintf ( 'Offset must be a positive integer or zero, %d given' , $ offset ) ) ; } if ( $ offset > 0 && !...
Adds an driver - specific LIMIT clause to the query .
3,260
protected function doModifyLimitQuery ( $ query , $ limit , $ offset ) { if ( $ limit !== null ) { $ query .= ' LIMIT ' . $ limit ; } if ( $ offset > 0 ) { $ query .= ' OFFSET ' . $ offset ; } return $ query ; }
Adds an platform - specific LIMIT clause to the query .
3,261
final public function getReservedKeywordsList ( ) { if ( $ this -> _keywords ) { return $ this -> _keywords ; } $ class = $ this -> getReservedKeywordsClass ( ) ; $ keywords = new $ class ( ) ; if ( ! $ keywords instanceof KeywordList ) { throw DBALException :: notSupported ( __METHOD__ ) ; } $ this -> _keywords = $ ke...
Returns the keyword list instance of this platform .
3,262
public function quoteStringLiteral ( $ str ) { $ c = $ this -> getStringLiteralQuoteCharacter ( ) ; return $ c . str_replace ( $ c , $ c . $ c , $ str ) . $ c ; }
Quotes a literal string . This method is NOT meant to fix SQL injections! It is only meant to escape this platform s string literal quote character inside the given literal string .
3,263
final public function escapeStringForLike ( string $ inputString , string $ escapeChar ) : string { return preg_replace ( '~([' . preg_quote ( $ this -> getLikeWildcardCharacters ( ) . $ escapeChar , '~' ) . '])~u' , addcslashes ( $ escapeChar , '\\' ) . '$1' , $ inputString ) ; }
Escapes metacharacters in a string intended to be used with a LIKE operator .
3,264
public static function getConnection ( array $ params , ? Configuration $ config = null , ? EventManager $ eventManager = null ) : Connection { if ( ! $ config ) { $ config = new Configuration ( ) ; } if ( ! $ eventManager ) { $ eventManager = new EventManager ( ) ; } $ params = self :: parseDatabaseUrl ( $ params ) ; ...
Creates a connection object based on the specified parameters . This method returns a Doctrine \ DBAL \ Connection which wraps the underlying driver connection .
3,265
private static function _checkParams ( array $ params ) : void { if ( ! isset ( $ params [ 'driver' ] ) && ! isset ( $ params [ 'driverClass' ] ) ) { throw DBALException :: driverRequired ( ) ; } if ( isset ( $ params [ 'driver' ] ) && ! isset ( self :: $ _driverMap [ $ params [ 'driver' ] ] ) ) { throw DBALException :...
Checks the list of parameters .
3,266
private static function parseDatabaseUrl ( array $ params ) : array { if ( ! isset ( $ params [ 'url' ] ) ) { return $ params ; } $ url = preg_replace ( '#^((?:pdo_)?sqlite3?):///#' , '$1://localhost/' , $ params [ 'url' ] ) ; assert ( is_string ( $ url ) ) ; $ url = parse_url ( $ url ) ; if ( $ url === false ) { throw...
Extracts parts from a database URL if present and returns an updated list of parameters .
3,267
private static function parseDatabaseUrlPath ( array $ url , array $ params ) : array { if ( ! isset ( $ url [ 'path' ] ) ) { return $ params ; } $ url [ 'path' ] = self :: normalizeDatabaseUrlPath ( $ url [ 'path' ] ) ; if ( ! isset ( $ params [ 'driver' ] ) ) { return self :: parseRegularDatabaseUrlPath ( $ url , $ p...
Parses the given connection URL and resolves the given connection parameters .
3,268
private static function parseDatabaseUrlQuery ( array $ url , array $ params ) : array { if ( ! isset ( $ url [ 'query' ] ) ) { return $ params ; } $ query = [ ] ; parse_str ( $ url [ 'query' ] , $ query ) ; return array_merge ( $ params , $ query ) ; }
Parses the query part of the given connection URL and resolves the given connection parameters .
3,269
private static function parseSqliteDatabaseUrlPath ( array $ url , array $ params ) : array { if ( $ url [ 'path' ] === ':memory:' ) { $ params [ 'memory' ] = true ; return $ params ; } $ params [ 'path' ] = $ url [ 'path' ] ; return $ params ; }
Parses the given SQLite connection URL and resolves the given connection parameters .
3,270
private static function parseDatabaseUrlScheme ( array $ url , array $ params ) : array { if ( isset ( $ url [ 'scheme' ] ) ) { unset ( $ params [ 'driverClass' ] ) ; $ driver = str_replace ( '-' , '_' , $ url [ 'scheme' ] ) ; assert ( is_string ( $ driver ) ) ; $ params [ 'driver' ] = self :: $ driverSchemeAliases [ $...
Parses the scheme part from given connection URL and resolves the given connection parameters .
3,271
private function killUserSessions ( $ user ) { $ sql = <<<SQLSELECT s.sid, s.serial#FROM gv\$session s, gv\$process pWHERE s.username = ? AND p.addr(+) = s.paddrSQL ; $ activeUserSessions = $ this -> _conn -> fetchAll ( $ sql , [ strtoupper ( $ user ) ] ) ; foreach ( $ activeUserSessions as $ activeU...
Kills sessions connected with the given user .
3,272
private function _constructPdoDsn ( array $ params ) { $ dsn = 'ibm:' ; if ( isset ( $ params [ 'host' ] ) ) { $ dsn .= 'HOSTNAME=' . $ params [ 'host' ] . ';' ; } if ( isset ( $ params [ 'port' ] ) ) { $ dsn .= 'PORT=' . $ params [ 'port' ] . ';' ; } $ dsn .= 'PROTOCOL=TCPIP;' ; if ( isset ( $ params [ 'dbname' ] ) ) ...
Constructs the IBM PDO DSN .
3,273
public function getQueries ( ) { return array_merge ( $ this -> createNamespaceQueries , $ this -> createTableQueries , $ this -> createSequenceQueries , $ this -> createFkConstraintQueries ) ; }
Gets all queries collected so far .
3,274
public static function fromSqlSrvErrors ( ) { $ message = '' ; $ sqlState = null ; $ errorCode = null ; foreach ( ( array ) sqlsrv_errors ( SQLSRV_ERR_ERRORS ) as $ error ) { $ message .= 'SQLSTATE [' . $ error [ 'SQLSTATE' ] . ', ' . $ error [ 'code' ] . ']: ' . $ error [ 'message' ] . "\n" ; if ( $ sqlState === null ...
Helper method to turn sql server errors into exception .
3,275
private function getRemainingForeignKeyConstraintsRequiringRenamedIndexes ( TableDiff $ diff ) { if ( empty ( $ diff -> renamedIndexes ) || ! $ diff -> fromTable instanceof Table ) { return [ ] ; } $ foreignKeys = [ ] ; $ remainingForeignKeys = array_diff_key ( $ diff -> fromTable -> getForeignKeys ( ) , $ diff -> remo...
Returns the remaining foreign key constraints that require one of the renamed indexes .
3,276
private function prepare ( ) { $ params = [ ] ; foreach ( $ this -> variables as $ column => & $ variable ) { switch ( $ this -> types [ $ column ] ) { case ParameterType :: LARGE_OBJECT : $ params [ $ column - 1 ] = [ & $ variable , SQLSRV_PARAM_IN , SQLSRV_PHPTYPE_STREAM ( SQLSRV_ENC_BINARY ) , SQLSRV_SQLTYPE_VARBINA...
Prepares SQL Server statement resource
3,277
public static function conversionFailed ( $ value , $ toType ) { $ value = strlen ( $ value ) > 32 ? substr ( $ value , 0 , 20 ) . '...' : $ value ; return new self ( 'Could not convert database value "' . $ value . '" to Doctrine Type ' . $ toType ) ; }
Thrown when a Database to Doctrine Type Conversion fails .
3,278
public static function conversionFailedFormat ( $ value , $ toType , $ expectedFormat , ? Throwable $ previous = null ) { $ value = strlen ( $ value ) > 32 ? substr ( $ value , 0 , 20 ) . '...' : $ value ; return new self ( 'Could not convert database value "' . $ value . '" to Doctrine Type ' . $ toType . '. Expected ...
Thrown when a Database to Doctrine Type Conversion fails and we can make a statement about the expected format .
3,279
public function setFilterSchemaAssetsExpression ( $ filterExpression ) { $ this -> _attributes [ 'filterSchemaAssetsExpression' ] = $ filterExpression ; if ( $ filterExpression ) { $ this -> _attributes [ 'filterSchemaAssetsExpressionCallable' ] = $ this -> buildSchemaAssetsFilterFromExpression ( $ filterExpression ) ;...
Sets the filter schema assets expression .
3,280
public function spansColumns ( array $ columnNames ) { $ columns = $ this -> getColumns ( ) ; $ numberOfColumns = count ( $ columns ) ; $ sameColumns = true ; for ( $ i = 0 ; $ i < $ numberOfColumns ; $ i ++ ) { if ( isset ( $ columnNames [ $ i ] ) && $ this -> trimQuotes ( strtolower ( $ columns [ $ i ] ) ) === $ this...
Checks if this index exactly spans the given column names in the correct order .
3,281
public function isFullfilledBy ( Index $ other ) { if ( count ( $ other -> getColumns ( ) ) !== count ( $ this -> getColumns ( ) ) ) { return false ; } $ sameColumns = $ this -> spansColumns ( $ other -> getColumns ( ) ) ; if ( $ sameColumns ) { if ( ! $ this -> samePartialIndex ( $ other ) ) { return false ; } if ( ! ...
Checks if the other index already fulfills all the indexing and constraint needs of the current one .
3,282
public function overrules ( Index $ other ) { if ( $ other -> isPrimary ( ) ) { return false ; } if ( $ this -> isSimpleIndex ( ) && $ other -> isUnique ( ) ) { return false ; } return $ this -> spansColumns ( $ other -> getColumns ( ) ) && ( $ this -> isPrimary ( ) || $ this -> isUnique ( ) ) && $ this -> samePartialI...
Detects if the other index is a non - unique non primary index that can be overwritten by this one .
3,283
private function samePartialIndex ( Index $ other ) { if ( $ this -> hasOption ( 'where' ) && $ other -> hasOption ( 'where' ) && $ this -> getOption ( 'where' ) === $ other -> getOption ( 'where' ) ) { return true ; } return ! $ this -> hasOption ( 'where' ) && ! $ other -> hasOption ( 'where' ) ; }
Return whether the two indexes have the same partial index
3,284
private function hasSameColumnLengths ( self $ other ) : bool { $ filter = static function ( ? int $ length ) : bool { return $ length !== null ; } ; return array_filter ( $ this -> options [ 'lengths' ] ?? [ ] , $ filter ) === array_filter ( $ other -> options [ 'lengths' ] ?? [ ] , $ filter ) ; }
Returns whether the index has the same column lengths as the other
3,285
private function getSequenceCacheSQL ( Sequence $ sequence ) { if ( $ sequence -> getCache ( ) === 0 ) { return ' NOCACHE' ; } if ( $ sequence -> getCache ( ) === 1 ) { return ' NOCACHE' ; } if ( $ sequence -> getCache ( ) > 1 ) { return ' CACHE ' . $ sequence -> getCache ( ) ; } return '' ; }
Cache definition for sequences
3,286
public function getDropAutoincrementSql ( $ table ) { $ table = $ this -> normalizeIdentifier ( $ table ) ; $ autoincrementIdentifierName = $ this -> getAutoincrementIdentifierName ( $ table ) ; $ identitySequenceName = $ this -> getIdentitySequenceName ( $ table -> isQuoted ( ) ? $ table -> getQuotedName ( $ this ) : ...
Returns the SQL statements to drop the autoincrement for the given table name .
3,287
private function normalizeIdentifier ( $ name ) { $ identifier = new Identifier ( $ name ) ; return $ identifier -> isQuoted ( ) ? $ identifier : new Identifier ( strtoupper ( $ name ) ) ; }
Normalizes the given identifier .
3,288
private function getAutoincrementIdentifierName ( Identifier $ table ) { $ identifierName = $ table -> getName ( ) . '_AI_PK' ; return $ table -> isQuoted ( ) ? $ this -> quoteSingleIdentifier ( $ identifierName ) : $ identifierName ; }
Returns the autoincrement primary key identifier name for the given table identifier .
3,289
public function setPrimaryKey ( array $ columnNames , $ indexName = false ) { $ this -> _addIndex ( $ this -> _createIndex ( $ columnNames , $ indexName ? : 'primary' , true , true ) ) ; foreach ( $ columnNames as $ columnName ) { $ column = $ this -> getColumn ( $ columnName ) ; $ column -> setNotnull ( true ) ; } ret...
Sets the Primary Key .
3,290
public function columnsAreIndexed ( array $ columnNames ) { foreach ( $ this -> getIndexes ( ) as $ index ) { if ( $ index -> spansColumns ( $ columnNames ) ) { return true ; } } return false ; }
Checks if an index begins in the order of the given columns .
3,291
public function changeColumn ( $ columnName , array $ options ) { $ column = $ this -> getColumn ( $ columnName ) ; $ column -> setOptions ( $ options ) ; return $ this ; }
Change Column Details .
3,292
public function dropColumn ( $ columnName ) { $ columnName = $ this -> normalizeIdentifier ( $ columnName ) ; unset ( $ this -> _columns [ $ columnName ] ) ; return $ this ; }
Drops a Column from the Table .
3,293
public function addNamedForeignKeyConstraint ( $ name , $ foreignTable , array $ localColumnNames , array $ foreignColumnNames , array $ options = [ ] ) { if ( $ foreignTable instanceof Table ) { foreach ( $ foreignColumnNames as $ columnName ) { if ( ! $ foreignTable -> hasColumn ( $ columnName ) ) { throw SchemaExcep...
Adds a foreign key constraint with a given name .
3,294
public function hasForeignKey ( $ constraintName ) { $ constraintName = $ this -> normalizeIdentifier ( $ constraintName ) ; return isset ( $ this -> _fkConstraints [ $ constraintName ] ) ; }
Returns whether this table has a foreign key constraint with the given name .
3,295
public function getForeignKey ( $ constraintName ) { $ constraintName = $ this -> normalizeIdentifier ( $ constraintName ) ; if ( ! $ this -> hasForeignKey ( $ constraintName ) ) { throw SchemaException :: foreignKeyDoesNotExist ( $ constraintName , $ this -> _name ) ; } return $ this -> _fkConstraints [ $ constraintNa...
Returns the foreign key constraint with the given name .
3,296
private function getForeignKeyColumns ( ) { $ foreignKeyColumns = [ ] ; foreach ( $ this -> getForeignKeys ( ) as $ foreignKey ) { $ foreignKeyColumns = array_merge ( $ foreignKeyColumns , $ foreignKey -> getColumns ( ) ) ; } return $ this -> filterColumns ( $ foreignKeyColumns ) ; }
Returns foreign key columns
3,297
private function filterColumns ( array $ columnNames ) { return array_filter ( $ this -> _columns , static function ( $ columnName ) use ( $ columnNames ) { return in_array ( $ columnName , $ columnNames , true ) ; } , ARRAY_FILTER_USE_KEY ) ; }
Returns only columns that have specified names
3,298
public function hasColumn ( $ columnName ) { $ columnName = $ this -> normalizeIdentifier ( $ columnName ) ; return isset ( $ this -> _columns [ $ columnName ] ) ; }
Returns whether this table has a Column with the given name .
3,299
public function getColumn ( $ columnName ) { $ columnName = $ this -> normalizeIdentifier ( $ columnName ) ; if ( ! $ this -> hasColumn ( $ columnName ) ) { throw SchemaException :: columnDoesNotExist ( $ columnName , $ this -> _name ) ; } return $ this -> _columns [ $ columnName ] ; }
Returns the Column with the given name .