idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
18,900 | public static function numericality ( $ cls , $ id , $ attr , $ attr_value , $ validation_value , $ options ) { return preg_match ( "/^[-\.0-9]+$/" , trim ( $ attr_value ) ) ; } | Check if an attribute is numeric |
18,901 | public static function hasMany ( $ attr , $ options = null ) { $ cls = get_called_class ( ) ; if ( ! array_key_exists ( $ cls , self :: $ _has_many ) ) { self :: $ _has_many [ $ cls ] = array ( ) ; } self :: $ _has_many [ $ cls ] [ $ attr ] = $ options ? $ options : false ; $ klass = self :: hasManyClass ( $ attr ) ; $... | Create a has many relationship |
18,902 | public static function hasHasMany ( $ attr ) { $ cls = get_called_class ( ) ; return array_key_exists ( $ cls , self :: $ _has_many ) && array_key_exists ( $ attr , self :: $ _has_many [ $ cls ] ) ; } | Check if there is a has many association |
18,903 | private static function _checkAndReturnMany ( $ method , $ value ) { $ cls = get_called_class ( ) ; if ( array_key_exists ( $ cls , self :: $ _has_many ) && array_key_exists ( $ method , self :: $ _has_many [ $ cls ] ) ) { return self :: _resolveHasMany ( $ method , $ value ) ; } } | Check a has many association and returns it resolved if exists . |
18,904 | public static function hasManyForeignKey ( $ attr ) { if ( ! self :: hasHasMany ( $ attr ) ) { return null ; } $ cls = get_called_class ( ) ; $ configs = self :: $ _has_many [ $ cls ] [ $ attr ] ; $ key = is_array ( $ configs ) && array_key_exists ( "foreign_key" , $ configs ) ? $ configs [ "foreign_key" ] : ( self :: ... | Check if there is a has many foreign key |
18,905 | private static function _resolveHasMany ( $ attr , $ value ) { $ cls = get_called_class ( ) ; if ( ! self :: hasHasMany ( $ attr ) ) { return null ; } $ configs = self :: $ _has_many [ $ cls ] [ $ attr ] ; $ has_many_cls = self :: hasManyClass ( $ attr ) ; $ this_key = self :: hasManyForeignKey ( $ attr ) ; $ collectio... | Resolve the has many association and returns the collection with values |
18,906 | private function _resolveIds ( $ attr , $ values = null ) { $ cls = get_called_class ( ) ; if ( ! array_key_exists ( $ cls , self :: $ _has_many_maps ) || ! array_key_exists ( $ attr , self :: $ _has_many_maps [ $ cls ] ) ) { return null ; } $ klass = self :: hasManyClass ( self :: $ _has_many_maps [ $ cls ] [ $ attr ]... | Resolve has many ids |
18,907 | private function _resolveCollection ( $ attr , $ values ) { $ cls = get_called_class ( ) ; if ( ! array_key_exists ( $ cls , self :: $ _has_many_maps ) ) { return null ; } $ maps = array_values ( self :: $ _has_many_maps [ $ cls ] ) ; if ( ! in_array ( $ attr , $ maps ) ) { return null ; } if ( ! $ values || ! is_array... | Set values to a has many association from an array |
18,908 | private function _nullNotPresentIds ( $ klass , $ foreign , $ ids , $ id ) { $ escape = Driver :: $ escape_char ; $ klasspk = $ klass :: getPK ( ) ; $ klass = strtolower ( $ klass ) ; $ table = Model :: getTableName ( $ klass ) ; $ sql = "update $escape$table$escape set $escape$foreign$escape=null where $escape$foreign... | Nullify foreign class keys not present in array |
18,909 | public function push ( $ obj ) { if ( ! $ obj ) { return ; } $ cls = get_called_class ( ) ; $ escape = Driver :: $ escape_char ; $ value = array_key_exists ( self :: getPK ( ) , $ this -> _data ) ? $ this -> _data [ self :: getPK ( ) ] : null ; $ other_cls = get_class ( $ obj ) ; $ other_pk = $ other_cls :: getPK ( ) ;... | Push an objet to a has many association |
18,910 | public static function getInstance ( ) { if ( ! isset ( self :: $ _instance ) ) { $ c = __CLASS__ ; self :: $ _instance = new $ c ; } return self :: $ _instance ; } | Get cache instance |
18,911 | public function put ( $ sql , $ cls = null ) { $ this -> expireCache ( ) ; $ hash = self :: _sqlHash ( $ sql ) ; if ( array_key_exists ( $ hash , $ this -> _prepared_cache ) ) { Log :: log ( "SQL: already prepared:\n$sql" ) ; return $ this -> _prepared_cache [ $ hash ] [ "statement" ] ; } else { Log :: log ( "SQL: inse... | Put a prepared statement on cache if not there . |
18,912 | public function get ( $ sql ) { $ this -> expireCache ( ) ; $ hash = self :: _sqlHash ( $ sql ) ; if ( ! array_key_exists ( $ hash , $ this -> _prepared_cache ) ) { return null ; } return $ this -> _prepared_cache [ $ hash ] [ "statement" ] ; } | Get a prepared statement from cache |
18,913 | public static function belongsTo ( $ model , $ options = null ) { $ cls = get_called_class ( ) ; if ( ! array_key_exists ( $ cls , self :: $ _belongs_to ) ) { self :: $ _belongs_to [ $ cls ] = array ( ) ; } self :: $ _belongs_to [ $ cls ] [ $ model ] = $ options ? $ options : false ; } | Create a belongs relationship |
18,914 | private function _checkAndReturnBelongs ( $ attr , $ values ) { $ cls = get_called_class ( ) ; if ( array_key_exists ( $ cls , self :: $ _belongs_to ) && array_key_exists ( $ attr , self :: $ _belongs_to [ $ cls ] ) ) { return $ this -> _resolveBelongsTo ( $ attr , $ values ) ; } } | Check if is there a belongs to association and return it |
18,915 | private function _resolveBelongsTo ( $ attr , $ values ) { $ cls = get_called_class ( ) ; if ( ! array_key_exists ( $ cls , self :: $ _belongs_to ) || ! array_key_exists ( $ attr , self :: $ _belongs_to [ $ cls ] ) ) { return null ; } $ configs = self :: $ _belongs_to [ $ cls ] [ $ attr ] ; $ belongs_cls = is_array ( $... | Resolve a belongs to association |
18,916 | public static function scope ( $ name , $ conditions ) { $ cls = get_called_class ( ) ; if ( ! array_key_exists ( $ cls , self :: $ _scopes ) ) { self :: $ _scopes [ $ cls ] = array ( ) ; } if ( ! array_key_exists ( $ name , self :: $ _scopes [ $ cls ] ) ) { self :: $ _scopes [ $ cls ] [ $ name ] = array ( ) ; } self :... | Create a scope |
18,917 | public static function getScope ( $ name , $ cls = null ) { if ( ! $ cls ) { $ cls = get_called_class ( ) ; } if ( ! array_key_exists ( $ cls , self :: $ _scopes ) || ! array_key_exists ( $ name , self :: $ _scopes [ $ cls ] ) ) { return null ; } return self :: $ _scopes [ $ cls ] [ $ name ] ; } | Return a scope |
18,918 | public static function resolveScope ( $ name , $ args = null , $ cls = null ) { $ conditions = self :: getScope ( $ name , $ cls ) ; if ( ! $ conditions ) { return null ; } if ( is_callable ( $ conditions ) ) { $ conditions = $ conditions ( $ args ) ; } return self :: where ( $ conditions ) ; } | Resolve a scope returning a collection |
18,919 | public function connect ( $ host , $ port , $ timeout = null ) { $ uuid = $ this -> uuid ( $ host , $ port ) ; if ( $ timeout === null ) { $ timeout = $ this -> getTimeout ( ) ; } $ errorNumber = null ; $ errorString = 'n.a.' ; if ( isset ( self :: $ connections [ $ this -> getPersistentId ( ) ] [ $ uuid ] ) === false ... | Connects to a Memcached host . |
18,920 | public function send ( $ command , $ data = '' ) { $ this -> reset ( ) ; if ( in_array ( $ command , $ this -> allowedCommands ) === false ) { throw new Exception ( sprintf ( 'The command "%s" is not allowed!' , $ command ) ) ; } $ socket = $ this -> connect ( $ this -> getHost ( ) , $ this -> getPort ( ) ) ; $ buffer ... | Sends a command to a Memcached instance and returns the parsed result . |
18,921 | public function touch ( $ key , $ expiration ) { $ data = self :: COMMAND_TOUCH . self :: COMMAND_SEPARATOR . $ key . self :: COMMAND_SEPARATOR . $ expiration . self :: COMMAND_TERMINATOR ; return $ this -> send ( self :: COMMAND_TOUCH , $ data ) ; } | Touch an existing key by offset . |
18,922 | public function incr ( $ key , $ offset = 1 ) { $ data = self :: COMMAND_INCR . self :: COMMAND_SEPARATOR . $ key . self :: COMMAND_SEPARATOR . $ offset . self :: COMMAND_TERMINATOR ; return $ this -> send ( self :: COMMAND_INCR , $ data ) ; } | Increments an existing key by offset . Does currently not support the creation of not existing keys . |
18,923 | public function decr ( $ key , $ offset = 1 ) { $ data = self :: COMMAND_DECR . self :: COMMAND_SEPARATOR . $ key . self :: COMMAND_SEPARATOR . $ offset . self :: COMMAND_TERMINATOR ; return $ this -> send ( self :: COMMAND_DECR , $ data ) ; } | Decrements an existing key by offset . Does currently not support the creation of not existing keys . |
18,924 | public function set ( $ key , $ value , $ expiration = 0 , $ flags = 0 , $ bytes = null ) { $ serialized = $ this -> serializeValue ( $ value ) ; $ value = $ serialized [ 'value' ] ; $ flags = $ serialized [ 'flags' ] ; $ bytes = $ serialized [ 'bytes' ] ; $ bytes = ( $ bytes !== null ) ? $ bytes : strlen ( $ value ) ;... | Sets a key with value and the passed metadata on Memcached instance . set means store this data . |
18,925 | public function append ( $ key , $ value , $ expiration = 0 , $ flags = self :: FLAG_DEFAULT , $ bytes = null ) { $ bytes = ( $ bytes !== null ) ? $ bytes : strlen ( $ value ) ; $ data = self :: COMMAND_APPEND . self :: COMMAND_SEPARATOR . $ key . self :: COMMAND_SEPARATOR . $ flags . self :: COMMAND_SEPARATOR . $ expi... | Appends a key with value and the passed metadata on Memcached instance . append means add this data to an existing key after existing data . |
18,926 | public function prepend ( $ key , $ value , $ expiration = 0 , $ flags = self :: FLAG_DEFAULT , $ bytes = null ) { $ bytes = ( $ bytes !== null ) ? $ bytes : strlen ( $ value ) ; $ data = self :: COMMAND_PREPEND . self :: COMMAND_SEPARATOR . $ key . self :: COMMAND_SEPARATOR . $ flags . self :: COMMAND_SEPARATOR . $ ex... | Prepends data to an existing key before existing data . prepend means add this data to an existing key before existing data . |
18,927 | public function cas ( $ token , $ key , $ value , $ expiration = 0 , $ flags = self :: FLAG_DEFAULT , $ bytes = null ) { $ serialized = $ this -> serializeValue ( $ value ) ; $ value = $ serialized [ 'value' ] ; $ flags = $ serialized [ 'flags' ] ; $ bytes = $ serialized [ 'bytes' ] ; $ bytes = ( $ bytes !== null ) ? $... | Tries to set a key value pair by using a cas token . If value was updated between the moment when retrieving the cas - value and the moment now calling this method the cas has changed and update will fail . |
18,928 | public function get ( $ key , $ metadata = false ) { $ data = self :: COMMAND_GET . self :: COMMAND_SEPARATOR . $ key . self :: COMMAND_TERMINATOR ; $ result = $ this -> send ( self :: COMMAND_GET , $ data ) ; if ( $ metadata === false && $ result !== false ) { $ result = array_column ( $ result , 'value' , 0 ) ; $ res... | Returns the response for passed key . |
18,929 | public function gets ( array $ keys , $ metadata = false ) { $ keys = implode ( self :: COMMAND_SEPARATOR , $ keys ) ; $ data = self :: COMMAND_GETS . self :: COMMAND_SEPARATOR . $ keys . self :: COMMAND_TERMINATOR ; $ result = $ this -> send ( self :: COMMAND_GETS , $ data ) ; if ( $ metadata === false ) { $ result = ... | Returns the response for passed keys . |
18,930 | public function stats ( $ type = '' , $ argument1 = '' , $ argument2 = '' ) { if ( $ type !== '' ) { $ type = self :: COMMAND_SEPARATOR . $ type ; } if ( $ argument1 !== '' ) { $ argument1 = self :: COMMAND_SEPARATOR . $ argument1 ; } if ( $ argument2 !== '' ) { $ argument2 = self :: COMMAND_SEPARATOR . $ argument2 ; }... | Stats - sends the stats command with default or custom type to Memcached instance . |
18,931 | public function version ( ) { $ data = self :: COMMAND_VERSION . self :: COMMAND_TERMINATOR ; return $ this -> send ( self :: COMMAND_VERSION , $ data ) ; } | Version - sends the version command to Memcached instance and returns the result . |
18,932 | public function flush_all ( ) { $ data = self :: COMMAND_FLUSH_ALL . self :: COMMAND_TERMINATOR ; return $ this -> send ( self :: COMMAND_FLUSH_ALL , $ data ) ; } | Flush - sends the flush_all command to Memcached instance and returns the result . |
18,933 | protected function parseVersionResponse ( array $ lines ) { $ metaData = explode ( self :: COMMAND_SEPARATOR , $ lines [ 0 ] ) ; if ( $ metaData [ 0 ] === strtoupper ( self :: COMMAND_VERSION ) ) { $ result = $ metaData [ 1 ] ; } else { $ result = $ this -> setLastResponse ( self :: MEMCACHED_FAILURE ) ; } return $ res... | Parser for response of version request . |
18,934 | protected function parseArithmeticResponse ( $ buffer , array $ lines ) { $ metaData = explode ( self :: COMMAND_SEPARATOR , $ lines [ 0 ] ) ; if ( $ buffer === self :: RESPONSE_NOT_FOUND . self :: COMMAND_TERMINATOR ) { $ result = $ this -> setLastResponse ( self :: MEMCACHED_NOTFOUND ) ; } else { $ result = ( float )... | Parser for response of arithmetic request . |
18,935 | protected function checkResponse ( $ buffer ) { if ( preg_match ( '/' . self :: ERROR . '(.*)\R/mu' , $ buffer , $ error ) > 0 ) { $ result = self :: MEMCACHED_FAILURE ; } elseif ( preg_match ( '/' . self :: ERROR_CLIENT . '(.*)\R/mu' , $ buffer , $ error ) > 0 ) { $ result = self :: RESPONSE_CLIENT_ERROR ; } elseif ( ... | Checks if a response contains some sort of hard errors or if it is parseable by the further process . |
18,936 | protected function parseResponse ( $ command , $ buffer ) { $ response = substr ( $ buffer , 0 , strlen ( $ buffer ) - strlen ( self :: COMMAND_TERMINATOR ) ) ; $ lines = explode ( self :: COMMAND_TERMINATOR , $ response ) ; $ result = false ; if ( $ command === self :: COMMAND_GET || $ command === self :: COMMAND_GETS... | Parses a response from a Memcached daemon |
18,937 | protected function serializeValue ( $ value ) { if ( $ this -> isSerializable ( $ value ) === true ) { $ value = serialize ( $ value ) ; $ bytes = strlen ( $ value ) ; $ flags = self :: FLAG_DECIMAL_SERIALIZED ; } else { if ( is_int ( $ value ) === true ) { $ flags = self :: FLAG_DECIMAL_INTEGER ; } elseif ( is_float (... | Serializes a value if it is serializable in our meaning . |
18,938 | private function handleError ( $ error , Http \ Request $ request , Http \ Response $ response ) { $ response = $ response -> withStatus ( $ this -> getStatusCode ( $ error , $ response ) ) ; $ message = $ response -> getReasonPhrase ( ) ? : 'Unknown Error' ; if ( ! isset ( $ this -> options [ 'env' ] ) || $ this -> op... | Handle an error condition |
18,939 | private function create404 ( Http \ Request $ request , Http \ Response $ response ) { $ response = $ response -> withStatus ( 404 ) ; $ originalRequest = $ request -> getOriginalRequest ( ) ; $ uri = $ originalRequest -> getUri ( ) ; $ escaper = new Escaper ( ) ; $ message = sprintf ( "Cannot %s %s\n" , $ escaper -> e... | Create a 404 status in the response |
18,940 | private function getStatusCode ( $ error , Http \ Response $ response ) { if ( $ error instanceof Exception && ( $ error -> getCode ( ) >= 400 && $ error -> getCode ( ) < 600 ) ) { return $ error -> getCode ( ) ; } $ status = $ response -> getStatusCode ( ) ; if ( ! $ status || $ status < 400 || $ status >= 600 ) { $ s... | Determine status code |
18,941 | private function triggerError ( $ error , Http \ Request $ request , Http \ Response $ response ) { if ( ! isset ( $ this -> options [ 'onerror' ] ) || ! is_callable ( $ this -> options [ 'onerror' ] ) ) { return ; } $ onError = $ this -> options [ 'onerror' ] ; $ onError ( $ error , $ request , $ response ) ; } | Trigger the error listener if present |
18,942 | public static function log ( $ msg ) { if ( ! self :: $ _enabled ) { return ; } if ( is_null ( self :: $ _file ) ) { echo "log: $msg\n" ; return ; } return self :: _logToFile ( $ msg ) ; } | Send a message to log |
18,943 | private static function _logToFile ( $ msg ) { if ( is_null ( self :: $ _file ) || ( is_string ( self :: $ _file ) && ! self :: _openLogFile ( ) ) ) { return false ; } return fwrite ( self :: $ _file , "$msg\n" ) ; } | Write a message on file |
18,944 | public static function define ( $ name , $ attrs , $ options = null ) { self :: $ _factories [ $ name ] = $ attrs ; self :: $ _options [ $ name ] = $ options ; } | Define a factory |
18,945 | public static function get ( $ name ) { self :: load ( ) ; if ( ! array_key_exists ( $ name , self :: $ _factories ) ) { return null ; } return self :: $ _factories [ $ name ] ; } | Return a factory |
18,946 | public static function attributes_for ( $ name ) { self :: load ( ) ; $ data = self :: get ( $ name ) ; if ( ! $ data ) { return null ; } return $ data ; } | Attributes for a factory |
18,947 | public static function build ( $ name , $ create = false ) { self :: load ( ) ; $ data = self :: attributes_for ( $ name ) ; if ( ! $ data ) { return null ; } if ( is_array ( self :: $ _options [ $ name ] ) && array_key_exists ( "class_name" , self :: $ _options [ $ name ] ) ) { $ name = self :: $ _options [ $ name ] [... | Build a factory |
18,948 | public static function find ( $ id ) { self :: _checkLoaded ( ) ; $ pk = self :: isIgnoringCase ( ) ? strtolower ( self :: getPK ( ) ) : self :: getPK ( ) ; $ builder = self :: _makeBuilder ( ) ; $ builder -> fields = self :: extractColumns ( ) ; $ builder -> where = self :: _extractWhereConditions ( array ( $ pk => $ ... | Find an object by its primary key |
18,949 | private static function _getByPosition ( $ position , $ conditions = null ) { self :: _checkLoaded ( ) ; $ builder = self :: _makeBuilder ( ) ; $ builder -> fields = self :: extractColumns ( ) ; $ builder -> order = $ position == "first" ? self :: getOrder ( ) : self :: getReversedOrder ( ) ; $ builder -> where = self ... | Get result by position - first or last |
18,950 | public function anonymize ( $ address ) { $ packedAddress = inet_pton ( $ address ) ; if ( strlen ( $ packedAddress ) == 4 ) { return $ this -> anonymizeIPv4 ( $ address ) ; } elseif ( strlen ( $ packedAddress ) == 16 ) { return $ this -> anonymizeIPv6 ( $ address ) ; } else { return "" ; } } | Anonymize an IPv4 or IPv6 address . |
18,951 | private function _addError ( $ attr , $ msg ) { if ( ! array_key_exists ( $ attr , $ this -> errors ) ) { $ this -> errors [ $ attr ] = array ( ) ; } array_push ( $ this -> errors [ $ attr ] , $ msg ) ; } | Add an error to an attribute |
18,952 | public function fullMessages ( $ errors = null ) { if ( ! function_exists ( "yaml_parse" ) || is_null ( self :: $ yaml_file ) || ! file_exists ( self :: $ yaml_file ) ) { return array ( ) ; } $ rtn = array ( ) ; $ parsed = yaml_parse ( file_get_contents ( self :: $ yaml_file ) ) ; $ errors = is_null ( $ errors ) ? $ th... | Return textual and translated error messages |
18,953 | private static function _checkCallback ( $ cls , $ callback , $ context ) { self :: _initiateCallbacks ( $ cls ) ; foreach ( self :: $ _callbacks [ $ cls ] [ $ callback ] as $ func ) { if ( ! call_user_func ( array ( $ context , $ func ) ) ) { return false ; } } return true ; } | Check if a callback exists |
18,954 | protected function getEncodeBook ( ) { if ( self :: $ encodeBook === null ) { self :: $ encodeBook = array_flip ( self :: $ decodeBook ) ; } return self :: $ encodeBook ; } | Returns the book used to encode . |
18,955 | public function reload ( ) { $ data = $ this -> find ( $ this -> id ) -> getData ( ) ; $ this -> _setData ( $ data ) ; $ this -> _belongs_cache = array ( ) ; } | Reload the current object |
18,956 | public static function isIgnoringCase ( ) { $ cls = get_called_class ( ) ; if ( ! array_key_exists ( $ cls , self :: $ _ignorecase ) ) { return true ; } return self :: $ _ignorecase [ $ cls ] ; } | Check if is ignoring case |
18,957 | private static function _loadNullValues ( ) { $ values = array ( ) ; $ cls = get_called_class ( ) ; if ( ! array_key_exists ( $ cls , self :: $ _columns ) ) { return null ; } foreach ( self :: $ _columns [ $ cls ] as $ column ) { $ name = self :: isIgnoringCase ( ) ? strtolower ( $ column ) : $ column ; $ values [ $ co... | Load null values on row columns . Useful to new objects . |
18,958 | private static function _extractClassName ( $ cls ) { $ tokens = preg_split ( "/\\\\/" , $ cls ) ; $ size = sizeof ( $ tokens ) ; if ( $ size < 2 ) { return $ cls ; } return $ tokens [ $ size - 1 ] ; } | Extract namespace from class name |
18,959 | public static function getTableName ( $ cls = null ) { $ fullcls = $ cls ? $ cls : get_called_class ( ) ; if ( array_key_exists ( $ fullcls , self :: $ _table_name ) ) { return self :: $ _table_name [ $ fullcls ] ; } $ cls = self :: _extractClassName ( $ fullcls ) ; $ name = Inflections :: pluralize ( $ cls ) ; if ( se... | Returns the table name . If not specified one get the current class name and pluralize it . |
18,960 | public static function getPK ( ) { $ cls = get_called_class ( ) ; return array_key_exists ( $ cls , self :: $ _pk ) ? self :: $ _pk [ $ cls ] : "id" ; } | Returns the primary key column . |
18,961 | public static function getOrder ( ) { $ cls = get_called_class ( ) ; return array_key_exists ( $ cls , self :: $ _order ) ? self :: $ _order [ $ cls ] : "" ; } | Returns the default order . If not specified returns an empty string . |
18,962 | public static function getReversedOrder ( ) { $ sort = preg_match ( "/desc/i" , self :: getOrder ( ) ) ; $ sort = $ sort ? " ASC " : " DESC " ; return self :: getOrder ( ) ? self :: getOrder ( ) . " $sort" : "" ; } | Returns the inverse order . If DESC is specified returns ASC . |
18,963 | public static function setConnection ( $ con , $ env = "development" ) { $ cls = get_called_class ( ) ; if ( ! array_key_exists ( $ cls , self :: $ _connections ) ) { self :: $ _connections [ $ cls ] = array ( ) ; } self :: $ _connections [ $ cls ] [ $ env ] = $ con ; } | Sets a specific connection for the current model |
18,964 | public static function resolveConnection ( ) { $ cls = get_called_class ( ) ; $ env = Connection :: selectEnvironment ( ) ; if ( array_key_exists ( $ cls , self :: $ _connections ) && array_key_exists ( $ env , self :: $ _connections [ $ cls ] ) ) { return self :: $ _connections [ $ cls ] [ $ env ] ; } return self :: $... | Resolve the current connection handle . Get it from PDO or from the current class . |
18,965 | private static function _loadColumns ( ) { if ( ! self :: resolveConnection ( ) ) { return ; } $ cls = get_called_class ( ) ; self :: $ _columns [ $ cls ] = array ( ) ; $ escape = Driver :: $ escape_char ; $ type = Driver :: $ numeric_column ; $ rst = null ; $ check = false ; try { $ rst = self :: query ( "select id fr... | Load column info |
18,966 | public static function extractColumns ( ) { self :: _checkLoaded ( ) ; $ cls = get_called_class ( ) ; $ temp_columns = "" ; $ escape = Driver :: $ escape_char ; foreach ( self :: $ _columns [ $ cls ] as $ column ) { $ temp_columns .= "$escape" . self :: getTableName ( ) . "$escape.$escape" . self :: $ _mapping [ $ cls ... | Extract table columns string |
18,967 | public static function extractUpdateColumns ( $ values ) { $ cls = get_called_class ( ) ; $ temp_columns = "" ; $ escape = Driver :: $ escape_char ; foreach ( $ values as $ key => $ value ) { $ temp_columns .= "$escape" . self :: $ _mapping [ $ cls ] [ $ key ] . "$escape=?," ; } return substr ( $ temp_columns , 0 , str... | Extract update columns string |
18,968 | private static function _extractWhereConditions ( $ conditions ) { if ( ! $ conditions ) { return "" ; } $ cls = get_called_class ( ) ; $ escape = Driver :: $ escape_char ; if ( is_array ( $ conditions ) ) { if ( array_values ( $ conditions ) !== $ conditions ) { $ conditions = self :: _extractWhereAssociativeCondition... | Extract where conditions string |
18,969 | private static function _extractWhereAssociativeConditions ( $ conditions , $ cls , $ escape ) { $ temp_cond = "" ; foreach ( $ conditions as $ key => $ value ) { $ temp_cond .= "$escape" . self :: getTableName ( ) . "$escape.$escape" . self :: $ _mapping [ $ cls ] [ $ key ] . "$escape=? and " ; } return substr ( $ tem... | Extract where conditions string from an associative array |
18,970 | public static function extractWhereValues ( $ conditions ) { $ values = array ( ) ; if ( ! $ conditions ) { return $ values ; } if ( is_array ( $ conditions ) ) { if ( array_values ( $ conditions ) !== $ conditions ) { $ values = self :: _extractWhereAssociativeValues ( $ conditions ) ; } else { $ values = self :: _ext... | Extract where values from conditions |
18,971 | private static function _extractWhereAssociativeValues ( $ conditions ) { $ values = array ( ) ; foreach ( $ conditions as $ key => $ value ) { array_push ( $ values , $ value ) ; } return $ values ; } | Extract values from an associative array |
18,972 | private static function _makeBuilder ( ) { $ builder = new Builder ( ) ; $ builder -> table = self :: getTableName ( ) ; $ builder -> order = self :: getOrder ( ) ; $ builder -> cls = get_called_class ( ) ; return $ builder ; } | Create a query builder |
18,973 | private static function _checkLoaded ( ) { $ cls = get_called_class ( ) ; if ( ! array_key_exists ( $ cls , self :: $ _loaded ) ) { self :: $ _loaded [ $ cls ] = false ; } if ( ! self :: $ _loaded [ $ cls ] ) { self :: _loadColumns ( ) ; } } | Check if the object columns were loaded |
18,974 | public static function executePrepared ( $ obj , $ values = array ( ) ) { if ( ! self :: $ _loaded ) { self :: _loadColumns ( ) ; } if ( ! is_string ( $ obj ) && get_class ( $ obj ) == "TORM\Builder" ) { $ sql = $ obj -> toString ( ) ; } if ( is_string ( $ obj ) ) { $ sql = $ obj ; } if ( ! preg_match ( '/\?/' , $ sql ... | Execute a prepared statement trying to get it from cache . |
18,975 | public function get ( $ attr , $ current = true ) { if ( ! $ this -> _data || ! array_key_exists ( $ attr , $ this -> _data ) ) { return null ; } return Connection :: convertToEncoding ( $ current ? $ this -> _data [ $ attr ] : $ this -> _prev_data [ $ attr ] ) ; } | Get an attribute value |
18,976 | public function set ( $ attr , $ value ) { $ pk = self :: getPK ( ) ; if ( ! $ this -> _new_rec && $ attr == $ pk ) { return ; } $ this -> _data [ $ attr ] = $ value ; } | Set an attribute value |
18,977 | private function _resolveRelations ( $ attr ) { $ many = self :: _checkAndReturnMany ( $ attr , $ this -> _data [ self :: getPK ( ) ] ) ; if ( $ many ) { return $ many ; } $ belongs = $ this -> _checkAndReturnBelongs ( $ attr , $ this -> _data ) ; if ( $ belongs ) { return $ belongs ; } $ has_one = $ this -> _checkAndR... | Resolve relations on an attribute if present |
18,978 | public static function hasOne ( $ attr , $ options = null ) { $ cls = get_called_class ( ) ; if ( ! array_key_exists ( $ cls , self :: $ _has_one ) ) { self :: $ _has_one [ $ cls ] = array ( ) ; } self :: $ _has_one [ $ cls ] [ $ attr ] = $ options ? $ options : false ; } | Create a has one association |
18,979 | private function _resolveHasOne ( $ attr , $ value ) { $ cls = get_called_class ( ) ; if ( ! array_key_exists ( $ cls , self :: $ _has_one ) || ! array_key_exists ( $ attr , self :: $ _has_one [ $ cls ] ) ) { return null ; } if ( array_key_exists ( $ attr , $ this -> _has_one_cache ) && $ this -> _has_one_cache [ $ att... | Resolve the has one association and returns the object |
18,980 | private function _checkAndReturnHasOne ( $ method , $ value ) { $ cls = get_called_class ( ) ; if ( array_key_exists ( $ cls , self :: $ _has_one ) && array_key_exists ( $ method , self :: $ _has_one [ $ cls ] ) ) { return $ this -> _resolveHasOne ( $ method , $ value ) ; } } | Check and return the value of a has one association |
18,981 | private function _changedAttribute ( $ attr ) { preg_match ( '/(\w+)_(change|changed|was)$/' , $ attr , $ matches ) ; if ( sizeof ( $ matches ) < 1 ) { return null ; } $ attr = $ matches [ 1 ] ; $ meth = $ matches [ 2 ] ; $ cur = $ this -> get ( $ attr ) ; $ old = $ this -> get ( $ attr , false ) ; if ( $ meth == "was"... | Check if an attribute changed its value since object was loaded |
18,982 | public function changed ( $ attrs = false ) { $ changes = array ( ) ; $ cls = get_called_class ( ) ; foreach ( self :: $ _columns [ $ cls ] as $ column ) { if ( $ cls :: getPK ( ) == $ column || in_array ( strtolower ( $ column ) , array ( "created_at" , "updated_at" ) ) ) { continue ; } $ cur = $ this -> get ( $ colum... | Return what changed |
18,983 | public function page ( ) { $ page = Page :: html ( ) ; $ listings = $ this -> config ( 'blog' , 'listings' ) ; if ( $ page -> url [ 'format' ] != 'html' ) { $ file = ( preg_match ( '/\.(txt|json|xml|rdf|rss|atom)$/' , $ page -> url [ 'path' ] ) ) ? $ this -> folder . 'content/' . $ page -> url [ 'path' ] . '.twig' : nu... | Determine if there is any Blog content associated with the current url path . |
18,984 | public function getOrder ( $ request ) { if ( ! ( $ request instanceof MarketplaceWebServiceOrders_Model_GetOrderRequest ) ) { require_once ( dirname ( __FILE__ ) . '/Model/GetOrderRequest.php' ) ; $ request = new MarketplaceWebServiceOrders_Model_GetOrderRequest ( $ request ) ; } $ parameters = $ request -> toQueryPar... | Get Order This operation takes up to 50 order ids and returns the corresponding orders . |
18,985 | private function _convertGetOrder ( $ request ) { $ parameters = array ( ) ; $ parameters [ 'Action' ] = 'GetOrder' ; if ( $ request -> isSetSellerId ( ) ) { $ parameters [ 'SellerId' ] = $ request -> getSellerId ( ) ; } if ( $ request -> isSetMWSAuthToken ( ) ) { $ parameters [ 'MWSAuthToken' ] = $ request -> getMWSAu... | Convert GetOrderRequest to name value pairs |
18,986 | private function _convertListOrders ( $ request ) { $ parameters = array ( ) ; $ parameters [ 'Action' ] = 'ListOrders' ; if ( $ request -> isSetSellerId ( ) ) { $ parameters [ 'SellerId' ] = $ request -> getSellerId ( ) ; } if ( $ request -> isSetMWSAuthToken ( ) ) { $ parameters [ 'MWSAuthToken' ] = $ request -> getM... | Convert ListOrdersRequest to name value pairs |
18,987 | private function _extractHttpStatusCode ( $ headers ) { $ statusCode = null ; if ( 1 === preg_match ( "/(\\S+) +(\\d+) +([^\n\r]+)(?:\r?\n|\r)/" , $ headers , $ matches ) ) { $ statusCode = $ matches [ 2 ] ; } return $ statusCode ; } | parse the status line of a header string for the proper format and return the status code |
18,988 | private function _extractResponseHeaderMetadata ( $ rawHeaders ) { $ inputHeaders = preg_split ( "/\r\n|\n|\r/" , $ rawHeaders ) ; $ headers = array ( ) ; $ headers [ 'x-mws-request-id' ] = null ; $ headers [ 'x-mws-response-context' ] = null ; $ headers [ 'x-mws-timestamp' ] = null ; $ headers [ 'x-mws-quota-max' ] = ... | extract a ResponseHeaderMetadata object from the raw headers |
18,989 | public function setMessages ( $ value ) { if ( ! $ this -> _isNumericArray ( $ value ) ) { $ value = array ( $ value ) ; } $ this -> _fields [ 'Messages' ] [ 'FieldValue' ] = $ value ; return $ this ; } | Set the value of the Messages property . |
18,990 | public function setOrderStatus ( $ value ) { if ( ! $ this -> _isNumericArray ( $ value ) ) { $ value = array ( $ value ) ; } $ this -> _fields [ 'OrderStatus' ] [ 'FieldValue' ] = $ value ; return $ this ; } | Set the value of the OrderStatus property . |
18,991 | public function setMarketplaceId ( $ value ) { if ( ! $ this -> _isNumericArray ( $ value ) ) { $ value = array ( $ value ) ; } $ this -> _fields [ 'MarketplaceId' ] [ 'FieldValue' ] = $ value ; return $ this ; } | Set the value of the MarketplaceId property . |
18,992 | public function setFulfillmentChannel ( $ value ) { if ( ! $ this -> _isNumericArray ( $ value ) ) { $ value = array ( $ value ) ; } $ this -> _fields [ 'FulfillmentChannel' ] [ 'FieldValue' ] = $ value ; return $ this ; } | Set the value of the FulfillmentChannel property . |
18,993 | public function setPaymentMethod ( $ value ) { if ( ! $ this -> _isNumericArray ( $ value ) ) { $ value = array ( $ value ) ; } $ this -> _fields [ 'PaymentMethod' ] [ 'FieldValue' ] = $ value ; return $ this ; } | Set the value of the PaymentMethod property . |
18,994 | public function setTFMShipmentStatus ( $ value ) { if ( ! $ this -> _isNumericArray ( $ value ) ) { $ value = array ( $ value ) ; } $ this -> _fields [ 'TFMShipmentStatus' ] [ 'FieldValue' ] = $ value ; return $ this ; } | Set the value of the TFMShipmentStatus property . |
18,995 | public function this ( \ Twig_Template $ twig , $ key = null , $ value = null ) { $ name = $ twig -> getTemplateName ( ) ; if ( ! isset ( $ this -> plugin [ $ name ] ) ) { $ this -> plugin [ $ name ] = array ( ) ; } if ( func_num_args ( ) == 1 ) { return $ this -> plugin [ $ name ] ; } elseif ( is_null ( $ key ) ) { $ ... | A reference to the current template sort of . This enables your plugin macros to behave more like a class and these are your properties . |
18,996 | private function removeEval ( & $ pattern ) { if ( is_array ( $ pattern ) ) { foreach ( $ pattern as $ key => $ value ) { $ pattern [ $ key ] = $ this -> removeEval ( $ value ) ; } } elseif ( is_string ( $ pattern ) ) { $ pattern = trim ( $ pattern ) ; $ mods = strrpos ( $ pattern , substr ( $ pattern , 0 , 1 ) ) ; $ p... | Remove e eval modifier from pattern . |
18,997 | public function setOrderItems ( $ value ) { if ( ! $ this -> _isNumericArray ( $ value ) ) { $ value = array ( $ value ) ; } $ this -> _fields [ 'OrderItems' ] [ 'FieldValue' ] = $ value ; return $ this ; } | Set the value of the OrderItems property . |
18,998 | public function setPaymentExecutionDetail ( $ value ) { if ( ! $ this -> _isNumericArray ( $ value ) ) { $ value = array ( $ value ) ; } $ this -> _fields [ 'PaymentExecutionDetail' ] [ 'FieldValue' ] = $ value ; return $ this ; } | Set the value of the PaymentExecutionDetail property . |
18,999 | public function setPaymentMethodDetails ( $ value ) { if ( ! $ this -> _isNumericArray ( $ value ) ) { $ value = array ( $ value ) ; } $ this -> _fields [ 'PaymentMethodDetails' ] [ 'FieldValue' ] = $ value ; return $ this ; } | Set the value of the PaymentMethodDetails property . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.