idx int64 0 241k | question stringlengths 64 6.21k | target stringlengths 5 803 |
|---|---|---|
3,100 | public function add ( $ key , $ value ) { if ( ! is_null ( $ key ) ) { $ currentValue = Arr :: get ( $ this -> payload , $ key , [ ] ) ; if ( ! is_array ( $ currentValue ) ) { $ currentValue = Arr :: wrap ( $ currentValue ) ; } $ currentValue [ ] = $ value ; Arr :: set ( $ this -> payload , $ key , $ currentValue ) ; } return $ this ; } | Add a value . |
3,101 | public function addIfNotEmpty ( $ key , $ value ) { if ( empty ( $ value ) ) { return $ this ; } return $ this -> add ( $ key , $ value ) ; } | Add a value if it s not empty . |
3,102 | public function getName ( ) { $ name = $ this -> name ?? Str :: snake ( str_replace ( 'IndexConfigurator' , '' , class_basename ( $ this ) ) ) ; return config ( 'scout.prefix' ) . $ name ; } | Get th name . |
3,103 | protected function createWriteAlias ( ) { $ configurator = $ this -> getIndexConfigurator ( ) ; if ( ! in_array ( Migratable :: class , class_uses_recursive ( $ configurator ) ) ) { return ; } $ payload = ( new IndexPayload ( $ configurator ) ) -> set ( 'name' , $ configurator -> getWriteAlias ( ) ) -> get ( ) ; ElasticClient :: indices ( ) -> putAlias ( $ payload ) ; $ this -> info ( sprintf ( 'The %s alias for the %s index was created!' , $ configurator -> getWriteAlias ( ) , $ configurator -> getName ( ) ) ) ; } | Create an write alias . |
3,104 | protected function isTargetIndexExists ( ) { $ targetIndex = $ this -> argument ( 'target-index' ) ; $ payload = ( new RawPayload ( ) ) -> set ( 'index' , $ targetIndex ) -> get ( ) ; return ElasticClient :: indices ( ) -> exists ( $ payload ) ; } | Checks if the target index exists . |
3,105 | protected function createTargetIndex ( ) { $ targetIndex = $ this -> argument ( 'target-index' ) ; $ sourceIndexConfigurator = $ this -> getModel ( ) -> getIndexConfigurator ( ) ; $ payload = ( new RawPayload ( ) ) -> set ( 'index' , $ targetIndex ) -> setIfNotEmpty ( 'body.settings' , $ sourceIndexConfigurator -> getSettings ( ) ) -> setIfNotEmpty ( 'body.mappings._default_' , $ sourceIndexConfigurator -> getDefaultMapping ( ) ) -> get ( ) ; ElasticClient :: indices ( ) -> create ( $ payload ) ; $ this -> info ( sprintf ( 'The %s index was created.' , $ targetIndex ) ) ; } | Create a target index . |
3,106 | protected function updateTargetIndex ( ) { $ targetIndex = $ this -> argument ( 'target-index' ) ; $ sourceIndexConfigurator = $ this -> getModel ( ) -> getIndexConfigurator ( ) ; $ targetIndexPayload = ( new RawPayload ( ) ) -> set ( 'index' , $ targetIndex ) -> get ( ) ; $ indices = ElasticClient :: indices ( ) ; try { $ indices -> close ( $ targetIndexPayload ) ; if ( $ settings = $ sourceIndexConfigurator -> getSettings ( ) ) { $ targetIndexSettingsPayload = ( new RawPayload ( ) ) -> set ( 'index' , $ targetIndex ) -> set ( 'body.settings' , $ settings ) -> get ( ) ; $ indices -> putSettings ( $ targetIndexSettingsPayload ) ; } if ( $ defaultMapping = $ sourceIndexConfigurator -> getDefaultMapping ( ) ) { $ targetIndexMappingPayload = ( new RawPayload ( ) ) -> set ( 'index' , $ targetIndex ) -> set ( 'type' , '_default_' ) -> set ( 'body._default_' , $ defaultMapping ) -> get ( ) ; $ indices -> putMapping ( $ targetIndexMappingPayload ) ; } $ indices -> open ( $ targetIndexPayload ) ; } catch ( Exception $ exception ) { $ indices -> open ( $ targetIndexPayload ) ; throw $ exception ; } $ this -> info ( sprintf ( 'The index %s was updated.' , $ targetIndex ) ) ; } | Update the target index . |
3,107 | protected function updateTargetIndexMapping ( ) { $ sourceModel = $ this -> getModel ( ) ; $ sourceIndexConfigurator = $ sourceModel -> getIndexConfigurator ( ) ; $ targetIndex = $ this -> argument ( 'target-index' ) ; $ targetType = $ sourceModel -> searchableAs ( ) ; $ mapping = array_merge_recursive ( $ sourceIndexConfigurator -> getDefaultMapping ( ) , $ sourceModel -> getMapping ( ) ) ; if ( empty ( $ mapping ) ) { $ this -> warn ( sprintf ( 'The %s mapping is empty.' , get_class ( $ sourceModel ) ) ) ; return ; } $ payload = ( new RawPayload ( ) ) -> set ( 'index' , $ targetIndex ) -> set ( 'type' , $ targetType ) -> set ( 'body.' . $ targetType , $ mapping ) -> get ( ) ; ElasticClient :: indices ( ) -> putMapping ( $ payload ) ; $ this -> info ( sprintf ( 'The %s mapping was updated.' , $ targetIndex ) ) ; } | Update the target index mapping . |
3,108 | protected function isAliasExists ( $ name ) { $ payload = ( new RawPayload ( ) ) -> set ( 'name' , $ name ) -> get ( ) ; return ElasticClient :: indices ( ) -> existsAlias ( $ payload ) ; } | Check if an alias exists . |
3,109 | protected function deleteAlias ( $ name ) { $ aliases = $ this -> getAlias ( $ name ) ; if ( empty ( $ aliases ) ) { return ; } foreach ( $ aliases as $ index => $ alias ) { $ deletePayload = ( new RawPayload ( ) ) -> set ( 'index' , $ index ) -> set ( 'name' , $ name ) -> get ( ) ; ElasticClient :: indices ( ) -> deleteAlias ( $ deletePayload ) ; $ this -> info ( sprintf ( 'The %s alias for the %s index was deleted.' , $ name , $ index ) ) ; } } | Delete an alias . |
3,110 | protected function createAliasForTargetIndex ( $ name ) { $ targetIndex = $ this -> argument ( 'target-index' ) ; if ( $ this -> isAliasExists ( $ name ) ) { $ this -> deleteAlias ( $ name ) ; } $ payload = ( new RawPayload ( ) ) -> set ( 'index' , $ targetIndex ) -> set ( 'name' , $ name ) -> get ( ) ; ElasticClient :: indices ( ) -> putAlias ( $ payload ) ; $ this -> info ( sprintf ( 'The %s alias for the %s index was created.' , $ name , $ targetIndex ) ) ; } | Create an alias for the target index . |
3,111 | protected function deleteSourceIndex ( ) { $ sourceIndexConfigurator = $ this -> getModel ( ) -> getIndexConfigurator ( ) ; if ( $ this -> isAliasExists ( $ sourceIndexConfigurator -> getName ( ) ) ) { $ aliases = $ this -> getAlias ( $ sourceIndexConfigurator -> getName ( ) ) ; foreach ( $ aliases as $ index => $ alias ) { $ payload = ( new RawPayload ( ) ) -> set ( 'index' , $ index ) -> get ( ) ; ElasticClient :: indices ( ) -> delete ( $ payload ) ; $ this -> info ( sprintf ( 'The %s index was removed.' , $ index ) ) ; } } else { $ payload = ( new IndexPayload ( $ sourceIndexConfigurator ) ) -> get ( ) ; ElasticClient :: indices ( ) -> delete ( $ payload ) ; $ this -> info ( sprintf ( 'The %s index was removed.' , $ sourceIndexConfigurator -> getName ( ) ) ) ; } } | Delete the source index . |
3,112 | protected function updateIndex ( ) { $ configurator = $ this -> getIndexConfigurator ( ) ; $ indexPayload = ( new IndexPayload ( $ configurator ) ) -> get ( ) ; $ indices = ElasticClient :: indices ( ) ; if ( ! $ indices -> exists ( $ indexPayload ) ) { throw new LogicException ( sprintf ( 'Index %s doesn\'t exist' , $ configurator -> getName ( ) ) ) ; } try { $ indices -> close ( $ indexPayload ) ; if ( $ settings = $ configurator -> getSettings ( ) ) { $ indexSettingsPayload = ( new IndexPayload ( $ configurator ) ) -> set ( 'body.settings' , $ settings ) -> get ( ) ; $ indices -> putSettings ( $ indexSettingsPayload ) ; } if ( $ defaultMapping = $ configurator -> getDefaultMapping ( ) ) { $ indexMappingPayload = ( new IndexPayload ( $ configurator ) ) -> set ( 'type' , '_default_' ) -> set ( 'body._default_' , $ defaultMapping ) -> get ( ) ; $ indices -> putMapping ( $ indexMappingPayload ) ; } $ indices -> open ( $ indexPayload ) ; } catch ( Exception $ exception ) { $ indices -> open ( $ indexPayload ) ; throw $ exception ; } $ this -> info ( sprintf ( 'The index %s was updated!' , $ configurator -> getName ( ) ) ) ; } | Update the index . |
3,113 | protected function createWriteAlias ( ) { $ configurator = $ this -> getIndexConfigurator ( ) ; if ( ! in_array ( Migratable :: class , class_uses_recursive ( $ configurator ) ) ) { return ; } $ indices = ElasticClient :: indices ( ) ; $ existsPayload = ( new RawPayload ( ) ) -> set ( 'name' , $ configurator -> getWriteAlias ( ) ) -> get ( ) ; if ( $ indices -> existsAlias ( $ existsPayload ) ) { return ; } $ putPayload = ( new IndexPayload ( $ configurator ) ) -> set ( 'name' , $ configurator -> getWriteAlias ( ) ) -> get ( ) ; $ indices -> putAlias ( $ putPayload ) ; $ this -> info ( sprintf ( 'The %s alias for the %s index was created!' , $ configurator -> getWriteAlias ( ) , $ configurator -> getName ( ) ) ) ; } | Create a write alias . |
3,114 | public function useAlias ( $ alias ) { $ aliasGetter = 'get' . ucfirst ( $ alias ) . 'Alias' ; if ( ! method_exists ( $ this -> indexConfigurator , $ aliasGetter ) ) { throw new Exception ( sprintf ( 'The index configurator %s doesn\'t have getter for the %s alias.' , get_class ( $ this -> indexConfigurator ) , $ alias ) ) ; } $ this -> payload [ 'index' ] = call_user_func ( [ $ this -> indexConfigurator , $ aliasGetter ] ) ; return $ this ; } | Use an alias . |
3,115 | public function getMapping ( ) { $ mapping = $ this -> mapping ?? [ ] ; if ( $ this :: usesSoftDelete ( ) && config ( 'scout.soft_delete' , false ) ) { Arr :: set ( $ mapping , 'properties.__soft_deleted' , [ 'type' => 'integer' ] ) ; } return $ mapping ; } | Get the mapping . |
3,116 | public function getSearchRules ( ) { return isset ( $ this -> searchRules ) && count ( $ this -> searchRules ) > 0 ? $ this -> searchRules : [ SearchRule :: class ] ; } | Get the search rules . |
3,117 | public static function search ( $ query , $ callback = null ) { $ softDelete = static :: usesSoftDelete ( ) && config ( 'scout.soft_delete' , false ) ; if ( $ query == '*' ) { return new FilterBuilder ( new static , $ callback , $ softDelete ) ; } else { return new SearchBuilder ( new static , $ query , $ callback , $ softDelete ) ; } } | Execute the search . |
3,118 | public function whereRegexp ( $ field , $ value , $ flags = 'ALL' ) { $ this -> wheres [ 'must' ] [ ] = [ 'regexp' => [ $ field => [ 'value' => $ value , 'flags' => $ flags , ] , ] , ] ; return $ this ; } | Add a whereRegexp condition . |
3,119 | public function whereGeoDistance ( $ field , $ value , $ distance ) { $ this -> wheres [ 'must' ] [ ] = [ 'geo_distance' => [ 'distance' => $ distance , $ field => $ value , ] , ] ; return $ this ; } | Add a whereGeoDistance condition . |
3,120 | public function select ( $ fields ) { $ this -> select = array_merge ( $ this -> select , Arr :: wrap ( $ fields ) ) ; return $ this ; } | Select one or many fields . |
3,121 | public static function formatExceptionAsDataArray ( Inspector $ inspector , $ shouldAddTrace ) { $ exception = $ inspector -> getException ( ) ; $ response = [ 'type' => get_class ( $ exception ) , 'message' => $ exception -> getMessage ( ) , 'file' => $ exception -> getFile ( ) , 'line' => $ exception -> getLine ( ) , ] ; if ( $ shouldAddTrace ) { $ frames = $ inspector -> getFrames ( ) ; $ frameData = [ ] ; foreach ( $ frames as $ frame ) { $ frameData [ ] = [ 'file' => $ frame -> getFile ( ) , 'line' => $ frame -> getLine ( ) , 'function' => $ frame -> getFunction ( ) , 'class' => $ frame -> getClass ( ) , 'args' => $ frame -> getArgs ( ) , ] ; } $ response [ 'trace' ] = $ frameData ; } return $ response ; } | Returns all basic information about the exception in a simple array for further convertion to other languages |
3,122 | public function breakOnDelimiter ( $ delimiter , $ s ) { $ parts = explode ( $ delimiter , $ s ) ; foreach ( $ parts as & $ part ) { $ part = '<div class="delimiter">' . $ part . '</div>' ; } return implode ( $ delimiter , $ parts ) ; } | Makes sure that the given string breaks on the delimiter . |
3,123 | public function shorten ( $ path ) { if ( $ this -> applicationRootPath != "/" ) { $ path = str_replace ( $ this -> applicationRootPath , '…' , $ path ) ; } return $ path ; } | Replace the part of the path that all files have in common . |
3,124 | public function dumpArgs ( Frame $ frame ) { if ( ! $ this -> getDumper ( ) ) { return '' ; } $ html = '' ; $ numFrames = count ( $ frame -> getArgs ( ) ) ; if ( $ numFrames > 0 ) { $ html = '<ol class="linenums">' ; foreach ( $ frame -> getArgs ( ) as $ j => $ frameArg ) { $ html .= '<li>' . $ this -> dump ( $ frameArg ) . '</li>' ; } $ html .= '</ol>' ; } return $ html ; } | Format the args of the given Frame as a human readable html string |
3,125 | public function slug ( $ original ) { $ slug = str_replace ( " " , "-" , $ original ) ; $ slug = preg_replace ( '/[^\w\d\-\_]/i' , '' , $ slug ) ; return strtolower ( $ slug ) ; } | Convert a string to a slug version of itself |
3,126 | public function render ( $ template , array $ additionalVariables = null ) { $ variables = $ this -> getVariables ( ) ; $ variables [ "tpl" ] = $ this ; if ( $ additionalVariables !== null ) { $ variables = array_replace ( $ variables , $ additionalVariables ) ; } call_user_func ( function ( ) { extract ( func_get_arg ( 1 ) ) ; require func_get_arg ( 0 ) ; } , $ template , $ variables ) ; } | Given a template path render it within its own scope . This method also accepts an array of additional variables to be passed to the template . |
3,127 | public function pushHandler ( $ handler ) { if ( is_callable ( $ handler ) ) { $ handler = new CallbackHandler ( $ handler ) ; } if ( ! $ handler instanceof HandlerInterface ) { throw new InvalidArgumentException ( "Argument to " . __METHOD__ . " must be a callable, or instance of " . "Whoops\\Handler\\HandlerInterface" ) ; } $ this -> handlerStack [ ] = $ handler ; return $ this ; } | Pushes a handler to the end of the stack |
3,128 | public function unregister ( ) { if ( $ this -> isRegistered ) { $ this -> system -> restoreExceptionHandler ( ) ; $ this -> system -> restoreErrorHandler ( ) ; $ this -> isRegistered = false ; } return $ this ; } | Unregisters all handlers registered by this Whoops \ Run instance |
3,129 | public function allowQuit ( $ exit = null ) { if ( func_num_args ( ) == 0 ) { return $ this -> allowQuit ; } return $ this -> allowQuit = ( bool ) $ exit ; } | Should Whoops allow Handlers to force the script to quit? |
3,130 | public function silenceErrorsInPaths ( $ patterns , $ levels = 10240 ) { $ this -> silencedPatterns = array_merge ( $ this -> silencedPatterns , array_map ( function ( $ pattern ) use ( $ levels ) { return [ "pattern" => $ pattern , "levels" => $ levels , ] ; } , ( array ) $ patterns ) ) ; return $ this ; } | Silence particular errors in particular files |
3,131 | public function writeToOutput ( $ send = null ) { if ( func_num_args ( ) == 0 ) { return $ this -> sendOutput ; } return $ this -> sendOutput = ( bool ) $ send ; } | Should Whoops push output directly to the client? If this is false output will be returned by handleException |
3,132 | public static function translateErrorCode ( $ error_code ) { $ constants = get_defined_constants ( true ) ; if ( array_key_exists ( 'Core' , $ constants ) ) { foreach ( $ constants [ 'Core' ] as $ constant => $ value ) { if ( substr ( $ constant , 0 , 2 ) == 'E_' && $ value == $ error_code ) { return $ constant ; } } } return "E_UNKNOWN" ; } | Translate ErrorException code into the represented constant . |
3,133 | public function getPreviousExceptionInspector ( ) { if ( $ this -> previousExceptionInspector === null ) { $ previousException = $ this -> exception -> getPrevious ( ) ; if ( $ previousException ) { $ this -> previousExceptionInspector = new Inspector ( $ previousException ) ; } } return $ this -> previousExceptionInspector ; } | Returns an Inspector for a previous Exception if any . |
3,134 | public function getPreviousExceptions ( ) { if ( $ this -> previousExceptions === null ) { $ this -> previousExceptions = [ ] ; $ prev = $ this -> exception -> getPrevious ( ) ; while ( $ prev !== null ) { $ this -> previousExceptions [ ] = $ prev ; $ prev = $ prev -> getPrevious ( ) ; } } return $ this -> previousExceptions ; } | Returns an array of all previous exceptions for this inspector s exception |
3,135 | protected function getTrace ( $ e ) { $ traces = $ e -> getTrace ( ) ; if ( ! $ e instanceof \ ErrorException ) { return $ traces ; } if ( ! Misc :: isLevelFatal ( $ e -> getSeverity ( ) ) ) { return $ traces ; } if ( ! extension_loaded ( 'xdebug' ) || ! xdebug_is_enabled ( ) ) { return [ ] ; } $ stack = array_reverse ( xdebug_get_function_stack ( ) ) ; $ trace = debug_backtrace ( DEBUG_BACKTRACE_IGNORE_ARGS ) ; $ traces = array_diff_key ( $ stack , $ trace ) ; return $ traces ; } | Gets the backtrace from an exception . |
3,136 | protected function getExceptionFrames ( ) { $ frames = $ this -> getInspector ( ) -> getFrames ( ) ; if ( $ this -> getApplicationPaths ( ) ) { foreach ( $ frames as $ frame ) { foreach ( $ this -> getApplicationPaths ( ) as $ path ) { if ( strpos ( $ frame -> getFile ( ) , $ path ) === 0 ) { $ frame -> setApplication ( true ) ; break ; } } } } return $ frames ; } | Get the stack trace frames of the exception that is currently being handled . |
3,137 | protected function getExceptionCode ( ) { $ exception = $ this -> getException ( ) ; $ code = $ exception -> getCode ( ) ; if ( $ exception instanceof \ ErrorException ) { $ code = Misc :: translateErrorCode ( $ exception -> getSeverity ( ) ) ; } return ( string ) $ code ; } | Get the code of the exception that is currently being handled . |
3,138 | public function handleUnconditionally ( $ value = null ) { if ( func_num_args ( ) == 0 ) { return $ this -> handleUnconditionally ; } $ this -> handleUnconditionally = ( bool ) $ value ; } | Allows to disable all attempts to dynamically decide whether to handle or return prematurely . Set this to ensure that the handler will perform no matter what . |
3,139 | public function getEditorHref ( $ filePath , $ line ) { $ editor = $ this -> getEditor ( $ filePath , $ line ) ; if ( empty ( $ editor ) ) { return false ; } if ( ! isset ( $ editor [ 'url' ] ) || ! is_string ( $ editor [ 'url' ] ) ) { throw new UnexpectedValueException ( __METHOD__ . " should always resolve to a string or a valid editor array; got something else instead." ) ; } $ editor [ 'url' ] = str_replace ( "%line" , rawurlencode ( $ line ) , $ editor [ 'url' ] ) ; $ editor [ 'url' ] = str_replace ( "%file" , rawurlencode ( $ filePath ) , $ editor [ 'url' ] ) ; return $ editor [ 'url' ] ; } | Given a string file path and an integer file line executes the editor resolver and returns if available a string that may be used as the href property for that file reference . |
3,140 | protected function getResource ( $ resource ) { if ( isset ( $ this -> resourceCache [ $ resource ] ) ) { return $ this -> resourceCache [ $ resource ] ; } foreach ( $ this -> searchPaths as $ path ) { $ fullPath = $ path . "/$resource" ; if ( is_file ( $ fullPath ) ) { $ this -> resourceCache [ $ resource ] = $ fullPath ; return $ fullPath ; } } throw new RuntimeException ( "Could not find resource '$resource' in any resource paths." . "(searched: " . join ( ", " , $ this -> searchPaths ) . ")" ) ; } | Finds a resource by its relative path in all available search paths . The search is performed starting at the last search path and all the way back to the first enabling a cascading - type system of overrides for all resources . |
3,141 | public function setLogger ( $ logger = null ) { if ( ! ( is_null ( $ logger ) || $ logger instanceof LoggerInterface ) ) { throw new InvalidArgumentException ( 'Argument to ' . __METHOD__ . " must be a valid Logger Interface (aka. Monolog), " . get_class ( $ logger ) . ' given.' ) ; } $ this -> logger = $ logger ; } | Set the output logger interface . |
3,142 | public function addTraceToOutput ( $ addTraceToOutput = null ) { if ( func_num_args ( ) == 0 ) { return $ this -> addTraceToOutput ; } $ this -> addTraceToOutput = ( bool ) $ addTraceToOutput ; return $ this ; } | Add error trace to output . |
3,143 | public function addTraceFunctionArgsToOutput ( $ addTraceFunctionArgsToOutput = null ) { if ( func_num_args ( ) == 0 ) { return $ this -> addTraceFunctionArgsToOutput ; } if ( ! is_integer ( $ addTraceFunctionArgsToOutput ) ) { $ this -> addTraceFunctionArgsToOutput = ( bool ) $ addTraceFunctionArgsToOutput ; } else { $ this -> addTraceFunctionArgsToOutput = $ addTraceFunctionArgsToOutput ; } } | Add error trace function arguments to output . Set to True for all frame args or integer for the n first frame args . |
3,144 | public function generateResponse ( ) { $ exception = $ this -> getException ( ) ; return sprintf ( "%s: %s in file %s on line %d%s\n" , get_class ( $ exception ) , $ exception -> getMessage ( ) , $ exception -> getFile ( ) , $ exception -> getLine ( ) , $ this -> getTraceOutput ( ) ) ; } | Create plain text response and return it as a string |
3,145 | public function loggerOnly ( $ loggerOnly = null ) { if ( func_num_args ( ) == 0 ) { return $ this -> loggerOnly ; } $ this -> loggerOnly = ( bool ) $ loggerOnly ; } | Only output to logger . |
3,146 | private function getTraceOutput ( ) { if ( ! $ this -> addTraceToOutput ( ) ) { return '' ; } $ inspector = $ this -> getInspector ( ) ; $ frames = $ inspector -> getFrames ( ) ; $ response = "\nStack trace:" ; $ line = 1 ; foreach ( $ frames as $ frame ) { $ class = $ frame -> getClass ( ) ; $ template = "\n%3d. %s->%s() %s:%d%s" ; if ( ! $ class ) { $ template = "\n%3d. %s%s() %s:%d%s" ; } $ response .= sprintf ( $ template , $ line , $ class , $ frame -> getFunction ( ) , $ frame -> getFile ( ) , $ frame -> getLine ( ) , $ this -> getFrameArgsOutput ( $ frame , $ line ) ) ; $ line ++ ; } return $ response ; } | Get the exception trace as plain text . |
3,147 | public function map ( $ callable ) { $ this -> frames = array_map ( function ( $ frame ) use ( $ callable ) { $ frame = call_user_func ( $ callable , $ frame ) ; if ( ! $ frame instanceof Frame ) { throw new UnexpectedValueException ( "Callable to " . __METHOD__ . " must return a Frame object" ) ; } return $ frame ; } , $ this -> frames ) ; return $ this ; } | Map the collection of frames |
3,148 | public function topDiff ( FrameCollection $ parentFrames ) { $ diff = $ this -> frames ; $ parentFrames = $ parentFrames -> getArray ( ) ; $ p = count ( $ parentFrames ) - 1 ; for ( $ i = count ( $ diff ) - 1 ; $ i >= 0 && $ p >= 0 ; $ i -- ) { $ tailFrame = $ diff [ $ i ] ; if ( $ tailFrame -> equals ( $ parentFrames [ $ p ] ) ) { unset ( $ diff [ $ i ] ) ; } $ p -- ; } return $ diff ; } | Gets the innermost part of stack trace that is not the same as that of outer exception |
3,149 | public function getComments ( $ filter = null ) { $ comments = $ this -> comments ; if ( $ filter !== null ) { $ comments = array_filter ( $ comments , function ( $ c ) use ( $ filter ) { return $ c [ 'context' ] == $ filter ; } ) ; } return $ comments ; } | Returns all comments for this frame . Optionally allows a filter to only retrieve comments from a specific context . |
3,150 | public function getFileLines ( $ start = 0 , $ length = null ) { if ( null !== ( $ contents = $ this -> getFileContents ( ) ) ) { $ lines = explode ( "\n" , $ contents ) ; if ( $ length !== null ) { $ start = ( int ) $ start ; $ length = ( int ) $ length ; if ( $ start < 0 ) { $ start = 0 ; } if ( $ length <= 0 ) { throw new InvalidArgumentException ( "\$length($length) cannot be lower or equal to 0" ) ; } $ lines = array_slice ( $ lines , $ start , $ length , true ) ; } return $ lines ; } } | Returns the contents of the file for this frame as an array of lines and optionally as a clamped range of lines . |
3,151 | public function serialize ( ) { $ frame = $ this -> frame ; if ( ! empty ( $ this -> comments ) ) { $ frame [ '_comments' ] = $ this -> comments ; } return serialize ( $ frame ) ; } | Implements the Serializable interface with special steps to also save the existing comments . |
3,152 | public function unserialize ( $ serializedFrame ) { $ frame = unserialize ( $ serializedFrame ) ; if ( ! empty ( $ frame [ '_comments' ] ) ) { $ this -> comments = $ frame [ '_comments' ] ; unset ( $ frame [ '_comments' ] ) ; } $ this -> frame = $ frame ; } | Unserializes the frame data while also preserving any existing comment data . |
3,153 | public function equals ( Frame $ frame ) { if ( ! $ this -> getFile ( ) || $ this -> getFile ( ) === 'Unknown' || ! $ this -> getLine ( ) ) { return false ; } return $ frame -> getFile ( ) === $ this -> getFile ( ) && $ frame -> getLine ( ) === $ this -> getLine ( ) ; } | Compares Frame against one another |
3,154 | private function getColumnConstraintSQL ( $ table , $ column ) { return "SELECT SysObjects.[Name] FROM SysObjects INNER JOIN (SELECT [Name],[ID] FROM SysObjects WHERE XType = 'U') AS Tab ON Tab.[ID] = Sysobjects.[Parent_Obj] INNER JOIN sys.default_constraints DefCons ON DefCons.[object_id] = Sysobjects.[ID] INNER JOIN SysColumns Col ON Col.[ColID] = DefCons.[parent_column_id] AND Col.[ID] = Tab.[ID] WHERE Col.[Name] = " . $ this -> _conn -> quote ( $ column ) . ' AND Tab.[Name] = ' . $ this -> _conn -> quote ( $ table ) . ' ORDER BY Col.[Name]' ; } | Returns the SQL to retrieve the constraints for a given column . |
3,155 | private function closeActiveDatabaseConnections ( $ database ) { $ database = new Identifier ( $ database ) ; $ this -> _execSql ( sprintf ( 'ALTER DATABASE %s SET SINGLE_USER WITH ROLLBACK IMMEDIATE' , $ database -> getQuotedName ( $ this -> _platform ) ) ) ; } | Closes currently active connections on the given database . |
3,156 | public function getSQL ( ) { if ( $ this -> sql !== null && $ this -> state === self :: STATE_CLEAN ) { return $ this -> sql ; } switch ( $ this -> type ) { case self :: INSERT : $ sql = $ this -> getSQLForInsert ( ) ; break ; case self :: DELETE : $ sql = $ this -> getSQLForDelete ( ) ; break ; case self :: UPDATE : $ sql = $ this -> getSQLForUpdate ( ) ; break ; case self :: SELECT : default : $ sql = $ this -> getSQLForSelect ( ) ; break ; } $ this -> state = self :: STATE_CLEAN ; $ this -> sql = $ sql ; return $ sql ; } | Gets the complete SQL string formed by the current specifications of this QueryBuilder . |
3,157 | public function setParameter ( $ key , $ value , $ type = null ) { if ( $ type !== null ) { $ this -> paramTypes [ $ key ] = $ type ; } $ this -> params [ $ key ] = $ value ; return $ this ; } | Sets a query parameter for the query being constructed . |
3,158 | public function setParameters ( array $ params , array $ types = [ ] ) { $ this -> paramTypes = $ types ; $ this -> params = $ params ; return $ this ; } | Sets a collection of query parameters for the query being constructed . |
3,159 | public function groupBy ( $ groupBy ) { if ( empty ( $ groupBy ) ) { return $ this ; } $ groupBy = is_array ( $ groupBy ) ? $ groupBy : func_get_args ( ) ; return $ this -> add ( 'groupBy' , $ groupBy , false ) ; } | Specifies a grouping over the results of the query . Replaces any previously specified groupings if any . |
3,160 | private function getSQLForInsert ( ) { return 'INSERT INTO ' . $ this -> sqlParts [ 'from' ] [ 'table' ] . ' (' . implode ( ', ' , array_keys ( $ this -> sqlParts [ 'values' ] ) ) . ')' . ' VALUES(' . implode ( ', ' , $ this -> sqlParts [ 'values' ] ) . ')' ; } | Converts this instance into an INSERT string in SQL . |
3,161 | public function createPositionalParameter ( $ value , $ type = ParameterType :: STRING ) { $ this -> boundCounter ++ ; $ this -> setParameter ( $ this -> boundCounter , $ value , $ type ) ; return '?' ; } | Creates a new positional parameter and bind the given value to it . |
3,162 | protected function _constructPdoDsn ( array $ params ) { $ dsn = 'sqlite:' ; if ( isset ( $ params [ 'path' ] ) ) { $ dsn .= $ params [ 'path' ] ; } elseif ( isset ( $ params [ 'memory' ] ) ) { $ dsn .= ':memory:' ; } return $ dsn ; } | Constructs the Sqlite PDO DSN . |
3,163 | public static function getPlaceholderPositions ( $ statement , $ isPositional = true ) { return $ isPositional ? self :: getPositionalPlaceholderPositions ( $ statement ) : self :: getNamedPlaceholderPositions ( $ statement ) ; } | Gets an array of the placeholders in an sql statements as keys and their positions in the query string . |
3,164 | private static function getPositionalPlaceholderPositions ( string $ statement ) : array { return self :: collectPlaceholders ( $ statement , '?' , self :: POSITIONAL_TOKEN , static function ( string $ _ , int $ placeholderPosition , int $ fragmentPosition , array & $ carry ) : void { $ carry [ ] = $ placeholderPosition + $ fragmentPosition ; } ) ; } | Returns a zero - indexed list of placeholder position . |
3,165 | private static function getNamedPlaceholderPositions ( string $ statement ) : array { return self :: collectPlaceholders ( $ statement , ':' , self :: NAMED_TOKEN , static function ( string $ placeholder , int $ placeholderPosition , int $ fragmentPosition , array & $ carry ) : void { $ carry [ $ placeholderPosition + $ fragmentPosition ] = substr ( $ placeholder , 1 ) ; } ) ; } | Returns a map of placeholder positions to their parameter names . |
3,166 | private function isUnchangedBinaryColumn ( ColumnDiff $ columnDiff ) { $ columnType = $ columnDiff -> column -> getType ( ) ; if ( ! $ columnType instanceof BinaryType && ! $ columnType instanceof BlobType ) { return false ; } $ fromColumn = $ columnDiff -> fromColumn instanceof Column ? $ columnDiff -> fromColumn : null ; if ( $ fromColumn ) { $ fromColumnType = $ fromColumn -> getType ( ) ; if ( ! $ fromColumnType instanceof BinaryType && ! $ fromColumnType instanceof BlobType ) { return false ; } return count ( array_diff ( $ columnDiff -> changedProperties , [ 'type' , 'length' , 'fixed' ] ) ) === 0 ; } if ( $ columnDiff -> hasChanged ( 'type' ) ) { return false ; } return count ( array_diff ( $ columnDiff -> changedProperties , [ 'length' , 'fixed' ] ) ) === 0 ; } | Checks whether a given column diff is a logically unchanged binary type column . |
3,167 | private function convertSingleBooleanValue ( $ value , $ callback ) { if ( $ value === null ) { return $ callback ( null ) ; } if ( is_bool ( $ value ) || is_numeric ( $ value ) ) { return $ callback ( ( bool ) $ value ) ; } if ( ! is_string ( $ value ) ) { return $ callback ( true ) ; } if ( in_array ( strtolower ( trim ( $ value ) ) , $ this -> booleanLiterals [ 'false' ] , true ) ) { return $ callback ( false ) ; } if ( in_array ( strtolower ( trim ( $ value ) ) , $ this -> booleanLiterals [ 'true' ] , true ) ) { return $ callback ( true ) ; } throw new UnexpectedValueException ( "Unrecognized boolean literal '${value}'" ) ; } | Converts a single boolean value . |
3,168 | private function doConvertBooleans ( $ item , $ callback ) { if ( is_array ( $ item ) ) { foreach ( $ item as $ key => $ value ) { $ item [ $ key ] = $ this -> convertSingleBooleanValue ( $ value , $ callback ) ; } return $ item ; } return $ this -> convertSingleBooleanValue ( $ item , $ callback ) ; } | Converts one or multiple boolean values . |
3,169 | private function typeChangeBreaksDefaultValue ( ColumnDiff $ columnDiff ) : bool { if ( ! $ columnDiff -> fromColumn ) { return $ columnDiff -> hasChanged ( 'type' ) ; } $ oldTypeIsNumeric = $ this -> isNumericType ( $ columnDiff -> fromColumn -> getType ( ) ) ; $ newTypeIsNumeric = $ this -> isNumericType ( $ columnDiff -> column -> getType ( ) ) ; return $ columnDiff -> hasChanged ( 'type' ) && ! ( $ oldTypeIsNumeric && $ newTypeIsNumeric && $ columnDiff -> column -> getAutoincrement ( ) ) ; } | Check whether the type of a column is changed in a way that invalidates the default value for the column |
3,170 | private static function findPlaceholderOrOpeningQuote ( $ statement , & $ tokenOffset , & $ fragmentOffset , & $ fragments , & $ currentLiteralDelimiter , & $ paramMap ) { $ token = self :: findToken ( $ statement , $ tokenOffset , '/[?\'"]/' ) ; if ( ! $ token ) { return false ; } if ( $ token === '?' ) { $ position = count ( $ paramMap ) + 1 ; $ param = ':param' . $ position ; $ fragments [ ] = substr ( $ statement , $ fragmentOffset , $ tokenOffset - $ fragmentOffset ) ; $ fragments [ ] = $ param ; $ paramMap [ $ position ] = $ param ; $ tokenOffset += 1 ; $ fragmentOffset = $ tokenOffset ; return true ; } $ currentLiteralDelimiter = $ token ; ++ $ tokenOffset ; return true ; } | Finds next placeholder or opening quote . |
3,171 | private static function findClosingQuote ( $ statement , & $ tokenOffset , & $ currentLiteralDelimiter ) { $ token = self :: findToken ( $ statement , $ tokenOffset , '/' . preg_quote ( $ currentLiteralDelimiter , '/' ) . '/' ) ; if ( ! $ token ) { return false ; } $ currentLiteralDelimiter = false ; ++ $ tokenOffset ; return true ; } | Finds closing quote |
3,172 | private static function findToken ( $ statement , & $ offset , $ regex ) { if ( preg_match ( $ regex , $ statement , $ matches , PREG_OFFSET_CAPTURE , $ offset ) ) { $ offset = $ matches [ 0 ] [ 1 ] ; return $ matches [ 0 ] [ 0 ] ; } return null ; } | Finds the token described by regex starting from the given offset . Updates the offset with the position where the token was found . |
3,173 | private function convertParameterType ( int $ type ) : int { switch ( $ type ) { case ParameterType :: BINARY : return OCI_B_BIN ; case ParameterType :: LARGE_OBJECT : return OCI_B_BLOB ; default : return SQLT_CHR ; } } | Converts DBAL parameter type to oci8 parameter type |
3,174 | public function getQuotedLocalColumns ( AbstractPlatform $ platform ) { $ columns = [ ] ; foreach ( $ this -> _localColumnNames as $ column ) { $ columns [ ] = $ column -> getQuotedName ( $ platform ) ; } return $ columns ; } | Returns the quoted representation of the referencing table column names the foreign key constraint is associated with . |
3,175 | public function getUnqualifiedForeignTableName ( ) { $ name = $ this -> _foreignTableName -> getName ( ) ; $ position = strrpos ( $ name , '.' ) ; if ( $ position !== false ) { $ name = substr ( $ name , $ position ) ; } return strtolower ( $ name ) ; } | Returns the non - schema qualified foreign table name . |
3,176 | public function getQuotedForeignColumns ( AbstractPlatform $ platform ) { $ columns = [ ] ; foreach ( $ this -> _foreignColumnNames as $ column ) { $ columns [ ] = $ column -> getQuotedName ( $ platform ) ; } return $ columns ; } | Returns the quoted representation of the referenced table column names the foreign key constraint is associated with . |
3,177 | private function onEvent ( $ event ) { if ( isset ( $ this -> _options [ $ event ] ) ) { $ onEvent = strtoupper ( $ this -> _options [ $ event ] ) ; if ( ! in_array ( $ onEvent , [ 'NO ACTION' , 'RESTRICT' ] ) ) { return $ onEvent ; } } return false ; } | Returns the referential action for a given database operation on the referenced table the foreign key constraint is associated with . |
3,178 | public function intersectsIndexColumns ( Index $ index ) { foreach ( $ index -> getColumns ( ) as $ indexColumn ) { foreach ( $ this -> _localColumnNames as $ localColumn ) { if ( strtolower ( $ indexColumn ) === strtolower ( $ localColumn -> getName ( ) ) ) { return true ; } } } return false ; } | Checks whether this foreign key constraint intersects the given index columns . |
3,179 | public function startDatabase ( $ database ) { assert ( $ this -> _platform instanceof SQLAnywherePlatform ) ; $ this -> _execSql ( $ this -> _platform -> getStartDatabaseSQL ( $ database ) ) ; } | Starts a database . |
3,180 | public function stopDatabase ( $ database ) { assert ( $ this -> _platform instanceof SQLAnywherePlatform ) ; $ this -> _execSql ( $ this -> _platform -> getStopDatabaseSQL ( $ database ) ) ; } | Stops a database . |
3,181 | private function constructPdoDsn ( array $ params ) { $ dsn = 'oci:dbname=' . $ this -> getEasyConnectString ( $ params ) ; if ( isset ( $ params [ 'charset' ] ) ) { $ dsn .= ';charset=' . $ params [ 'charset' ] ; } return $ dsn ; } | Constructs the Oracle PDO DSN . |
3,182 | private function getOracleMysqlVersionNumber ( string $ versionString ) : string { if ( ! preg_match ( '/^(?P<major>\d+)(?:\.(?P<minor>\d+)(?:\.(?P<patch>\d+))?)?/' , $ versionString , $ versionParts ) ) { throw DBALException :: invalidPlatformVersionSpecified ( $ versionString , '<major_version>.<minor_version>.<patch_version>' ) ; } $ majorVersion = $ versionParts [ 'major' ] ; $ minorVersion = $ versionParts [ 'minor' ] ?? 0 ; $ patchVersion = $ versionParts [ 'patch' ] ?? null ; if ( $ majorVersion === '5' && $ minorVersion === '7' && $ patchVersion === null ) { $ patchVersion = '9' ; } return $ majorVersion . '.' . $ minorVersion . '.' . $ patchVersion ; } | Get a normalized version number from the server string returned by Oracle MySQL servers . |
3,183 | private function getMariaDbMysqlVersionNumber ( string $ versionString ) : string { if ( ! preg_match ( '/^(?:5\.5\.5-)?(mariadb-)?(?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)/i' , $ versionString , $ versionParts ) ) { throw DBALException :: invalidPlatformVersionSpecified ( $ versionString , '^(?:5\.5\.5-)?(mariadb-)?<major_version>.<minor_version>.<patch_version>' ) ; } return $ versionParts [ 'major' ] . '.' . $ versionParts [ 'minor' ] . '.' . $ versionParts [ 'patch' ] ; } | Detect MariaDB server version including hack for some mariadb distributions that starts with the prefix 5 . 5 . 5 - |
3,184 | private function getNonAutoincrementPrimaryKeyDefinition ( array $ columns , array $ options ) : string { if ( empty ( $ options [ 'primary' ] ) ) { return '' ; } $ keyColumns = array_unique ( array_values ( $ options [ 'primary' ] ) ) ; foreach ( $ keyColumns as $ keyColumn ) { if ( ! empty ( $ columns [ $ keyColumn ] [ 'autoincrement' ] ) ) { return '' ; } } return ', PRIMARY KEY(' . implode ( ', ' , $ keyColumns ) . ')' ; } | Generate a PRIMARY KEY definition if no autoincrement value is used |
3,185 | public function bindValue ( $ name , $ value , $ type = ParameterType :: STRING ) { $ this -> params [ $ name ] = $ value ; $ this -> types [ $ name ] = $ type ; if ( $ type !== null ) { if ( is_string ( $ type ) ) { $ type = Type :: getType ( $ type ) ; } if ( $ type instanceof Type ) { $ value = $ type -> convertToDatabaseValue ( $ value , $ this -> platform ) ; $ bindingType = $ type -> getBindingType ( ) ; } else { $ bindingType = $ type ; } return $ this -> stmt -> bindValue ( $ name , $ value , $ bindingType ) ; } return $ this -> stmt -> bindValue ( $ name , $ value ) ; } | Binds a parameter value to the statement . |
3,186 | public function bindParam ( $ name , & $ var , $ type = ParameterType :: STRING , $ length = null ) { $ this -> params [ $ name ] = $ var ; $ this -> types [ $ name ] = $ type ; return $ this -> stmt -> bindParam ( $ name , $ var , $ type , $ length ) ; } | Binds a parameter to a value by reference . |
3,187 | public function execute ( $ params = null ) { if ( is_array ( $ params ) ) { $ this -> params = $ params ; } $ logger = $ this -> conn -> getConfiguration ( ) -> getSQLLogger ( ) ; if ( $ logger ) { $ logger -> startQuery ( $ this -> sql , $ this -> params , $ this -> types ) ; } try { $ stmt = $ this -> stmt -> execute ( $ params ) ; } catch ( Throwable $ ex ) { if ( $ logger ) { $ logger -> stopQuery ( ) ; } throw DBALException :: driverExceptionDuringQuery ( $ this -> conn -> getDriver ( ) , $ ex , $ this -> sql , $ this -> conn -> resolveParams ( $ this -> params , $ this -> types ) ) ; } if ( $ logger ) { $ logger -> stopQuery ( ) ; } $ this -> params = [ ] ; $ this -> types = [ ] ; return $ stmt ; } | Executes the statement with the currently bound parameters . |
3,188 | protected function getAlterTableAddColumnClause ( Column $ column ) { return 'ADD ' . $ this -> getColumnDeclarationSQL ( $ column -> getQuotedName ( $ this ) , $ column -> toArray ( ) ) ; } | Returns the SQL clause for creating a column in a table alteration . |
3,189 | protected function getAlterTableRenameColumnClause ( $ oldColumnName , Column $ column ) { $ oldColumnName = new Identifier ( $ oldColumnName ) ; return 'RENAME ' . $ oldColumnName -> getQuotedName ( $ this ) . ' TO ' . $ column -> getQuotedName ( $ this ) ; } | Returns the SQL clause for renaming a column in a table alteration . |
3,190 | protected function getAlterTableChangeColumnClause ( ColumnDiff $ columnDiff ) { $ column = $ columnDiff -> column ; if ( ! ( $ columnDiff -> hasChanged ( 'comment' ) && count ( $ columnDiff -> changedProperties ) === 1 ) ) { $ columnAlterationClause = 'ALTER ' . $ this -> getColumnDeclarationSQL ( $ column -> getQuotedName ( $ this ) , $ column -> toArray ( ) ) ; if ( $ columnDiff -> hasChanged ( 'default' ) && $ column -> getDefault ( ) === null ) { $ columnAlterationClause .= ', ALTER ' . $ column -> getQuotedName ( $ this ) . ' DROP DEFAULT' ; } return $ columnAlterationClause ; } return null ; } | Returns the SQL clause for altering a column in a table alteration . |
3,191 | public function getForeignKeyMatchClauseSQL ( $ type ) { switch ( ( int ) $ type ) { case self :: FOREIGN_KEY_MATCH_SIMPLE : return 'SIMPLE' ; break ; case self :: FOREIGN_KEY_MATCH_FULL : return 'FULL' ; break ; case self :: FOREIGN_KEY_MATCH_SIMPLE_UNIQUE : return 'UNIQUE SIMPLE' ; break ; case self :: FOREIGN_KEY_MATCH_FULL_UNIQUE : return 'UNIQUE FULL' ; default : throw new InvalidArgumentException ( 'Invalid foreign key match type: ' . $ type ) ; } } | Returns foreign key MATCH clause for given type . |
3,192 | public function getPrimaryKeyDeclarationSQL ( Index $ index , $ name = null ) { if ( ! $ index -> isPrimary ( ) ) { throw new InvalidArgumentException ( 'Can only create primary key declarations with getPrimaryKeyDeclarationSQL()' ) ; } return $ this -> getTableConstraintDeclarationSQL ( $ index , $ name ) ; } | Obtain DBMS specific SQL code portion needed to set a primary key declaration to be used in statements like ALTER TABLE . |
3,193 | protected function getAdvancedIndexOptionsSQL ( Index $ index ) { $ sql = '' ; if ( ! $ index -> isPrimary ( ) && $ index -> hasFlag ( 'for_olap_workload' ) ) { $ sql .= ' FOR OLAP WORKLOAD' ; } return $ sql ; } | Return the INDEX query section dealing with non - standard SQL Anywhere options . |
3,194 | protected function getTableConstraintDeclarationSQL ( Constraint $ constraint , $ name = null ) { if ( $ constraint instanceof ForeignKeyConstraint ) { return $ this -> getForeignKeyDeclarationSQL ( $ constraint ) ; } if ( ! $ constraint instanceof Index ) { throw new InvalidArgumentException ( 'Unsupported constraint type: ' . get_class ( $ constraint ) ) ; } if ( ! $ constraint -> isPrimary ( ) && ! $ constraint -> isUnique ( ) ) { throw new InvalidArgumentException ( 'Can only create primary, unique or foreign key constraint declarations, no common index declarations ' . 'with getTableConstraintDeclarationSQL().' ) ; } $ constraintColumns = $ constraint -> getQuotedColumns ( $ this ) ; if ( empty ( $ constraintColumns ) ) { throw new InvalidArgumentException ( "Incomplete definition. 'columns' required." ) ; } $ sql = '' ; $ flags = '' ; if ( ! empty ( $ name ) ) { $ name = new Identifier ( $ name ) ; $ sql .= 'CONSTRAINT ' . $ name -> getQuotedName ( $ this ) . ' ' ; } if ( $ constraint -> hasFlag ( 'clustered' ) ) { $ flags = 'CLUSTERED ' ; } if ( $ constraint -> isPrimary ( ) ) { return $ sql . 'PRIMARY KEY ' . $ flags . '(' . $ this -> getIndexFieldDeclarationListSQL ( $ constraintColumns ) . ')' ; } return $ sql . 'UNIQUE ' . $ flags . '(' . $ this -> getIndexFieldDeclarationListSQL ( $ constraintColumns ) . ')' ; } | Returns the SQL snippet for creating a table constraint . |
3,195 | public function splitFederation ( $ splitDistributionValue ) { $ type = Type :: getType ( $ this -> distributionType ) ; $ sql = 'ALTER FEDERATION ' . $ this -> getFederationName ( ) . ' ' . 'SPLIT AT (' . $ this -> getDistributionKey ( ) . ' = ' . $ this -> conn -> quote ( $ splitDistributionValue , $ type -> getBindingType ( ) ) . ')' ; $ this -> conn -> exec ( $ sql ) ; } | Splits Federation at a given distribution value . |
3,196 | public static function compare ( $ version ) { $ currentVersion = str_replace ( ' ' , '' , strtolower ( self :: VERSION ) ) ; $ version = str_replace ( ' ' , '' , $ version ) ; return version_compare ( $ version , $ currentVersion ) ; } | Compares a Doctrine version with the current one . |
3,197 | public function connect ( $ shardId = null ) { if ( $ shardId === null && $ this -> _conn ) { return false ; } if ( $ shardId !== null && $ shardId === $ this -> activeShardId ) { return false ; } if ( $ this -> getTransactionNestingLevel ( ) > 0 ) { throw new ShardingException ( 'Cannot switch shard when transaction is active.' ) ; } $ activeShardId = $ this -> activeShardId = ( int ) $ shardId ; if ( isset ( $ this -> activeConnections [ $ activeShardId ] ) ) { $ this -> _conn = $ this -> activeConnections [ $ activeShardId ] ; return false ; } $ this -> _conn = $ this -> activeConnections [ $ activeShardId ] = $ this -> connectTo ( $ activeShardId ) ; if ( $ this -> _eventManager -> hasListeners ( Events :: postConnect ) ) { $ eventArgs = new ConnectionEventArgs ( $ this ) ; $ this -> _eventManager -> dispatchEvent ( Events :: postConnect , $ eventArgs ) ; } return true ; } | Connects to a given shard . |
3,198 | public function connect ( ) { if ( $ this -> isConnected ) { return false ; } $ driverOptions = $ this -> params [ 'driverOptions' ] ?? [ ] ; $ user = $ this -> params [ 'user' ] ?? null ; $ password = $ this -> params [ 'password' ] ?? null ; $ this -> _conn = $ this -> _driver -> connect ( $ this -> params , $ user , $ password , $ driverOptions ) ; $ this -> isConnected = true ; if ( $ this -> autoCommit === false ) { $ this -> beginTransaction ( ) ; } if ( $ this -> _eventManager -> hasListeners ( Events :: postConnect ) ) { $ eventArgs = new Event \ ConnectionEventArgs ( $ this ) ; $ this -> _eventManager -> dispatchEvent ( Events :: postConnect , $ eventArgs ) ; } return true ; } | Establishes the connection with the database . |
3,199 | private function detectDatabasePlatform ( ) { $ version = $ this -> getDatabasePlatformVersion ( ) ; if ( $ version !== null ) { assert ( $ this -> _driver instanceof VersionAwarePlatformDriver ) ; $ this -> platform = $ this -> _driver -> createDatabasePlatformForVersion ( $ version ) ; } else { $ this -> platform = $ this -> _driver -> getDatabasePlatform ( ) ; } $ this -> platform -> setEventManager ( $ this -> _eventManager ) ; } | Detects and sets the database platform . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.