idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
11,100
public function process ( ProjectDescriptor $ project ) { foreach ( $ this -> behaviours as $ behaviour ) { $ project = $ behaviour -> process ( $ project ) ; } return $ project ; }
Executes the behaviour on the given object model
11,101
protected function getConfigHelper ( $ serviceName ) { $ storage = new HydraTokenStorage ( ) ; $ provider = new DefaultServiceProvider ( $ storage ) ; $ className = $ this -> getConfigHelperClassName ( $ serviceName ) ; return new $ className ( $ storage , $ provider , $ serviceName ) ; }
overwrite for dependency injection
11,102
public function getPasswordHistories ( ) { if ( empty ( $ this -> passwordHistoryClass ) || ! class_exists ( $ this -> passwordHistoryClass ) ) { return false ; } $ class = $ this -> passwordHistoryClass ; return $ class :: find ( ) -> createdBy ( $ this ) -> orderByCreatedAt ( SORT_DESC ) -> all ( ) ; }
Get all password histories sorted by creation time in descending order .
11,103
public function onAddPasswordToHistory ( $ event ) { $ password = $ event -> data ; $ sender = $ event -> sender ; if ( empty ( $ sender -> passwordHistoryClass ) || ! class_exists ( $ sender -> passwordHistoryClass ) || empty ( $ sender -> passwordHashAttribute ) || ! is_string ( $ sender -> passwordHashAttribute ) ) ...
This event is ONLY used for adding password to history . You SHOULD NOT call this method directly or you know the consequences of doing so
11,104
public function checkPasswordNotUsed ( $ attribute , $ params , $ validator ) { $ class = $ this -> passwordHistoryClass ; $ result = $ class :: isUsed ( $ this -> _password , $ this ) ; if ( $ result != false ) { $ this -> trigger ( static :: $ eventPasswordUsed ) ; $ this -> addError ( $ attribute , $ this -> passwor...
This method is only used for password hash attribute validation . If password is used the eventPasswordUsed event will be triggered .
11,105
public function log ( $ db = null ) { if ( $ db instanceof \ PDO ) { \ sb \ Web \ Visitors :: $ db = $ db ; } return \ sb \ Web \ Visitors :: log ( $ this ) ; }
Logs a \ sb \ Web_Visitor in the database
11,106
protected function onList ( ) { Breadcrumbs :: register ( 'notifications' , function ( $ breadcrumbs ) { $ breadcrumbs -> push ( trans ( 'antares/notifications::messages.notification_templates' ) , handles ( 'antares::notifications/index' ) ) ; } ) ; view ( ) -> share ( 'breadcrumbs' , Breadcrumbs :: render ( 'notifica...
on list notifications
11,107
public function onTable ( $ type = null ) { if ( ! is_null ( $ type ) ) { Breadcrumbs :: register ( 'notifications-' . $ type , function ( $ breadcrumbs ) use ( $ type ) { $ breadcrumbs -> push ( 'Notifications ' . ucfirst ( $ type ) , handles ( 'antares::notifications/index' ) ) ; } ) ; view ( ) -> share ( 'breadcrumb...
when shows notifications list
11,108
public function onCreate ( $ type = null ) { $ this -> onList ( ) ; Breadcrumbs :: register ( 'notification-create' , function ( $ breadcrumbs ) { $ breadcrumbs -> parent ( 'notifications' ) ; $ breadcrumbs -> push ( trans ( 'antares/notifications::messages.notification_templates_create' ) ) ; } ) ; view ( ) -> share (...
when shows create new notification form
11,109
public static function getUri ( $ index , $ regex = ".*" ) { if ( self :: $ uri === array ( ) ) self :: $ uri = explode ( "/" , trim ( $ _GET [ 'dachi_uri' ] , " \t\n\r\0\x0B/" ) ) ; if ( isset ( self :: $ uri_variables [ $ index ] ) ) if ( $ regex == ".*" || preg_match ( "/^" . $ regex . "$/i" , self :: $ uri_variable...
Get a section of the URI
11,110
public static function getFullUri ( ) { if ( ! isset ( $ _GET [ 'dachi_uri' ] ) ) $ _GET [ 'dachi_uri' ] = "" ; if ( self :: $ uri === array ( ) && isset ( $ _GET [ 'dachi_uri' ] ) ) self :: $ uri = explode ( "/" , trim ( $ _GET [ 'dachi_uri' ] , " \t\n\r\0\x0B/" ) ) ; return self :: $ uri ; }
Get the whole URI
11,111
public static function setRequestVariables ( $ uri_variables , $ api_mode = false ) { if ( self :: $ uri === array ( ) && isset ( $ _GET [ 'dachi_uri' ] ) ) self :: $ uri = explode ( "/" , trim ( $ _GET [ 'dachi_uri' ] , " \t\n\r\0\x0B/" ) ) ; foreach ( $ uri_variables as $ var ) self :: $ uri_variables [ $ var [ 1 ] ]...
Set the variable mapping for URI componants .
11,112
public static function getArgument ( $ key , $ default = "default" , $ regex = ".*" ) { if ( self :: $ arguments === array ( ) ) self :: $ arguments = array_merge ( $ _GET , $ _POST , $ _FILES ) ; if ( isset ( self :: $ arguments [ $ key ] ) ) { if ( $ regex == ".*" || preg_match ( "/^" . $ regex . "$/i" , self :: $ ar...
Get an argument passed to the page
11,113
public static function getAllArguments ( ) { if ( self :: $ arguments === array ( ) ) self :: $ arguments = array_merge ( $ _GET , $ _POST , $ _FILES ) ; return self :: $ arguments ; }
Get all arguments passed to the page
11,114
public static function setCookie ( $ key , $ value , $ expire = - 1 , $ path = "/" , $ domain = null ) { if ( $ expire == - 1 ) $ expire = time ( ) + 2592000 ; return setcookie ( $ key , $ value , $ expire , $ path , $ domain ) ; }
Set a value in the user s cookie
11,115
public static function getData ( $ key ) { if ( ! isset ( self :: $ output_data [ $ key ] ) ) return false ; return self :: $ output_data [ $ key ] ; }
Get an outgoing request data variable
11,116
public static function isAjax ( ) { if ( Configuration :: get ( "dachi.api-mode" , false ) == true ) return true ; return ( self :: getArgument ( "dachi-ui" , "false" ) == "true" || self :: getArgument ( "radon-ui-ajax" , "false" ) == "true" ) ; }
Check if this request is being served via ajax
11,117
function install ( Connection $ db , Logger $ log ) { if ( $ this -> isApplied ( $ db ) ) { $ log -> info ( "Skipping " . $ this -> getName ( ) . ": already applied" ) ; return ; } foreach ( $ this -> getParents ( ) as $ migration ) { $ migration -> install ( $ db , $ log ) ; } if ( strlen ( $ this -> getName ( ) ) == ...
Install the current migration and any parent migrations that this migration depends on .
11,118
private function getRepositoryUrlWithVersionPath ( $ version ) { $ repositoryUrl = $ this -> repositoryUrl ; if ( in_array ( $ version , array ( 'master' , $ this -> trunkPath ) ) ) { $ repositoryUrl .= '/' . $ this -> trunkPath ; } elseif ( in_array ( $ version , $ this -> getBranches ( ) ) ) { $ repositoryUrl .= '/' ...
Returns the escaped repository URL with version path . Returns false when the repository URL for a version cannot be found .
11,119
private function build_message ( $ part ) { $ message = $ part [ "message" ] ; if ( $ part [ "encode" ] == "base64" ) { $ message = chunk_split ( base64_encode ( $ message ) ) ; } else if ( $ part [ "encode" ] == "quoted-printable" ) { $ message = $ this -> encode_qp ( $ message ) ; } return "Content-Type: " . $ part [...
void build_message ( array part = Build message parts of an multipart mail
11,120
function encodeSubject ( $ input , $ charset = 'ISO-8859-1' ) { $ old_enc = mb_internal_encoding ( ) ; mb_internal_encoding ( $ charset ) ; $ output = mb_encode_mimeheader ( $ input , $ charset , 'Q' , $ this -> LE ) ; mb_internal_encoding ( $ old_enc ) ; return $ output ; }
The method can be used to encode the subject which is in a non ascii encoding .
11,121
public function setOptions ( $ options ) { if ( ! empty ( $ options [ 'hosts' ] ) ) { foreach ( $ options [ 'hosts' ] as $ host => $ port ) { $ this -> addserver ( $ host , $ port , false ) ; } } else { $ this -> addserver ( '127.0.0.1' , '11211' , false ) ; } }
Stablish Memcached options defined in config . php
11,122
public function match ( string $ variable = null , array $ labels = [ ] ) : self { $ query = new self ; $ query -> clauses = $ this -> clauses -> add ( new Clause \ MatchClause ( Clause \ Expression \ Path :: startWithNode ( $ variable , $ labels ) ) ) ; return $ query ; }
Match the given node
11,123
public function maybeMatch ( string $ variable = null , array $ labels = [ ] ) : self { $ query = new self ; $ query -> clauses = $ this -> clauses -> add ( new Clause \ OptionalMatchClause ( Clause \ Expression \ Path :: startWithNode ( $ variable , $ labels ) ) ) ; return $ query ; }
Add a OPTIONAL MATCh clause
11,124
public function withParameter ( string $ key , $ parameter ) : self { $ clause = $ this -> clauses -> last ( ) ; if ( ! $ clause instanceof Clause \ Parametrable ) { throw new NonParametrableClause ; } $ clause = $ clause -> withParameter ( $ key , $ parameter ) ; $ query = new self ; $ query -> clauses = $ this -> cla...
Attach the given parameter to the last clause
11,125
public function withProperties ( array $ properties ) : self { $ query = $ this ; foreach ( $ properties as $ property => $ cypher ) { $ query = $ query -> withProperty ( $ property , $ cypher ) ; } return $ query ; }
Specify a set of properties to be matched
11,126
public function withProperty ( string $ property , string $ cypher ) : self { $ clause = $ this -> clauses -> last ( ) ; if ( ! $ clause instanceof Clause \ PathAware ) { throw new NonPathAwareClause ; } $ clause = $ clause -> withProperty ( $ property , $ cypher ) ; $ query = new self ; $ query -> clauses = $ this -> ...
Specify a property to be matched
11,127
public function linkedTo ( string $ variable = null , array $ labels = [ ] ) : self { $ clause = $ this -> clauses -> last ( ) ; if ( ! $ clause instanceof Clause \ PathAware ) { throw new NonPathAwareClause ; } $ clause = $ clause -> linkedTo ( $ variable , $ labels ) ; $ query = new self ; $ query -> clauses = $ this...
Match the node linked to the previous declared node match
11,128
public function through ( string $ type , string $ variable = null , string $ direction = 'BOTH' ) : self { $ clause = $ this -> clauses -> last ( ) ; if ( ! $ clause instanceof Clause \ PathAware ) { throw new NonPathAwareClause ; } $ clause = $ clause -> through ( $ variable , $ type , $ direction ) ; $ query = new s...
Specify the type of relationship for the last match clause
11,129
public function withADistanceOf ( int $ distance ) : self { $ clause = $ this -> clauses -> last ( ) ; if ( ! $ clause instanceof Clause \ PathAware ) { throw new NonPathAwareClause ; } $ clause = $ clause -> withADistanceOf ( $ distance ) ; $ query = new self ; $ query -> clauses = $ this -> clauses -> dropEnd ( 1 ) -...
Define the deepness of the relationship
11,130
public function with ( string ... $ variables ) : self { $ query = new self ; $ query -> clauses = $ this -> clauses -> add ( new Clause \ WithClause ( ... $ variables ) ) ; return $ query ; }
Add a WITH clause
11,131
public function where ( string $ cypher ) : self { $ query = new self ; $ query -> clauses = $ this -> clauses -> add ( new Clause \ WhereClause ( $ cypher ) ) ; return $ query ; }
Add a WHERE clause
11,132
public function set ( string $ cypher ) : self { $ query = new self ; $ query -> clauses = $ this -> clauses -> add ( new Clause \ SetClause ( $ cypher ) ) ; return $ query ; }
Add a SET clause
11,133
public function using ( string $ cypher ) : self { $ query = new self ; $ query -> clauses = $ this -> clauses -> add ( new Clause \ UsingClause ( $ cypher ) ) ; return $ query ; }
Add a USING clause
11,134
public function unwind ( string $ cypher ) : self { $ query = new self ; $ query -> clauses = $ this -> clauses -> add ( new Clause \ UnwindClause ( $ cypher ) ) ; return $ query ; }
Add a UNWIND clause
11,135
public function union ( ) : self { $ query = new self ; $ query -> clauses = $ this -> clauses -> add ( new Clause \ UnionClause ) ; return $ query ; }
Add a UNION clause
11,136
public function skip ( string $ cypher ) : self { $ query = new self ; $ query -> clauses = $ this -> clauses -> add ( new Clause \ SkipClause ( $ cypher ) ) ; return $ query ; }
Add a SKIP clause
11,137
public function return ( string ... $ variables ) : self { $ query = new self ; $ query -> clauses = $ this -> clauses -> add ( new Clause \ ReturnClause ( ... $ variables ) ) ; return $ query ; }
Add a RETURN clause
11,138
public function remove ( string $ cypher ) : self { $ query = new self ; $ query -> clauses = $ this -> clauses -> add ( new Clause \ RemoveClause ( $ cypher ) ) ; return $ query ; }
Add a REMOVE clause
11,139
public function orderBy ( string $ cypher , string $ direction = 'ASC' ) : self { $ direction = \ strtolower ( $ direction ) ; $ query = new self ; $ query -> clauses = $ this -> clauses -> add ( Clause \ OrderByClause :: $ direction ( $ cypher ) ) ; return $ query ; }
Add a ORDER BY clause
11,140
public function onMatch ( string $ cypher ) : self { $ clause = $ this -> clauses -> last ( ) ; if ( ! $ clause instanceof Clause \ MergeClause && ! $ clause instanceof Clause \ OnCreateClause ) { throw new NonMergeClause ; } $ query = new self ; $ query -> clauses = $ this -> clauses -> add ( new Clause \ OnMatchClaus...
Add a ON MATCH clause
11,141
public function merge ( string $ variable = null , array $ labels = [ ] ) : self { $ query = new self ; $ query -> clauses = $ this -> clauses -> add ( new Clause \ MergeClause ( Clause \ Expression \ Path :: startWithNode ( $ variable , $ labels ) ) ) ; return $ query ; }
Add a MERGE clause
11,142
public function limit ( string $ cypher ) : self { $ query = new self ; $ query -> clauses = $ this -> clauses -> add ( new Clause \ LimitClause ( $ cypher ) ) ; return $ query ; }
Add a LIMIT clause
11,143
public function foreach ( string $ cypher ) : self { $ query = new self ; $ query -> clauses = $ this -> clauses -> add ( new Clause \ ForeachClause ( $ cypher ) ) ; return $ query ; }
Add a FOREACH clause
11,144
public function delete ( string $ variable , bool $ detach = false ) : self { $ query = new self ; $ query -> clauses = $ this -> clauses -> add ( new Clause \ DeleteClause ( $ variable , $ detach ) ) ; return $ query ; }
Add a DELETE clause
11,145
public function create ( string $ variable , array $ labels = [ ] , bool $ unique = false ) : self { $ query = new self ; $ query -> clauses = $ this -> clauses -> add ( new Clause \ CreateClause ( Clause \ Expression \ Path :: startWithNode ( $ variable , $ labels ) , $ unique ) ) ; return $ query ; }
Add a CREATE clause
11,146
public function get_size ( ) { if ( $ this -> file && $ this -> size === 0 ) { $ this -> size = filesize ( $ this -> file ) ; } return $ this -> size ; }
Return the filesize in byte .
11,147
public function get_extension ( ) { if ( $ this -> name ) { if ( ! isset ( $ this -> ext ) ) { if ( strpos ( $ this -> name , '.' ) !== false ) { $ p = str :: file_ext ( $ this -> name , 1 ) ; $ this -> ext = $ p [ 1 ] ; $ this -> title = $ p [ 0 ] ; } else { $ this -> ext = '' ; $ this -> title = substr ( $ this -> na...
Return the extension of the file .
11,148
protected function make ( ) { if ( ! $ this -> file && strpos ( $ this -> path , 'http://' ) === 0 ) { $ d = getcwd ( ) ; chdir ( __DIR__ ) ; chdir ( '../tmp' ) ; $ f = tempnam ( '.' , 'image' ) ; try { $ c = file_get_contents ( $ this -> path . $ this -> name ) ; if ( file_put_contents ( $ f , $ c ) ) { if ( substr ( ...
Creates a temporary file in tmp directory .
11,149
public function download ( ) { if ( $ this -> file ) { if ( ! $ this -> size ) { $ this -> get_size ( ) ; } if ( $ this -> size && ( $ handle = fopen ( $ this -> file , 'r' ) ) ) { header ( 'Content-type: application/octet-stream' ) ; header ( 'Content-Disposition: attachment; filename="' . $ this -> name . '"' ) ; whi...
Downloads the file . At the end of the script the user will be invited to choose the file s destination . If the file doesn t exist return an object with parameter file = null .
11,150
public function save ( $ dest = './' ) { $ new_name = false ; if ( substr ( $ dest , - 1 ) === '/' ) { if ( is_dir ( $ dest ) ) { $ new_name = 0 ; } } else if ( is_dir ( $ dest ) ) { $ dest .= '/' ; $ new_name = 0 ; } else if ( is_dir ( substr ( $ dest , 0 , strrpos ( $ dest , '/' ) ) ) ) { $ new_name = 1 ; } if ( $ ne...
That feature saves the file as a parameter and accepts a string that contains the path where to save .
11,151
public function unconsume ( $ howMany = 1 ) { if ( ( $ this -> char - $ howMany ) >= 0 ) { $ this -> char = $ this -> char - $ howMany ; } }
Unconsume characters .
11,152
public function peek ( ) { if ( ( $ this -> char + 1 ) <= $ this -> EOF ) { return $ this -> data [ $ this -> char + 1 ] ; } return false ; }
Look ahead without moving cursor .
11,153
public function send ( ) { $ subject = 'EVENT' ; if ( $ this -> method == 'CANCEL' ) { $ subject = 'CANCELED ' . $ subject ; if ( empty ( $ this -> uid ) ) { throw ( new \ Exception ( 'Must set uid to cancel an event.' ) ) ; } } if ( ! empty ( $ this -> summary ) ) { $ subject .= ': ' . substr ( $ this -> summary , 0 ,...
Send via email the subject is the first 20 chars of the summary the message is the summary . The email is sent to the organizer s email The attendees all cc d
11,154
protected function enabled ( $ url ) { $ web = Web :: instance ( ) ; $ req = $ web -> request ( $ url ) ; $ found = FALSE ; if ( $ req && $ req [ 'body' ] ) { foreach ( $ req [ 'headers' ] as $ header ) if ( preg_match ( '/^X-Pingback:\h*(.+)/' , $ header , $ href ) ) { $ found = $ href [ 1 ] ; break ; } if ( ! $ found...
Return TRUE if URL points to a pingback - enabled resource
11,155
function inspect ( $ source ) { $ fw = Base :: instance ( ) ; $ web = Web :: instance ( ) ; $ parts = parse_url ( $ source ) ; if ( empty ( $ parts [ 'scheme' ] ) || empty ( $ parts [ 'host' ] ) || $ parts [ 'host' ] == $ fw -> get ( 'HOST' ) ) { $ req = $ web -> request ( $ source ) ; $ doc = new DOMDocument ( '1.0' ,...
Load local page contents parse HTML anchor tags find permalinks and send XML - RPC calls to corresponding pingback servers
11,156
function listen ( $ func , $ path = NULL ) { $ fw = Base :: instance ( ) ; if ( PHP_SAPI != 'cli' ) { header ( 'X-Powered-By: ' . $ fw -> get ( 'PACKAGE' ) ) ; header ( 'Content-Type: application/xml; ' . 'charset=' . $ charset = $ fw -> get ( 'ENCODING' ) ) ; } if ( ! $ path ) $ path = $ fw -> get ( 'BASE' ) ; $ web =...
Receive ping check if local page is pingback - enabled verify source contents and return XML - RPC response
11,157
protected function processFileSpecification ( $ artifact , $ fileSpecification ) { $ this -> aspectKernel -> addAspect ( new fphp \ Aspect \ Aspect ( $ artifact , $ fileSpecification ) ) ; $ this -> tracingLinks [ ] = new fphp \ Artifact \ TracingLink ( "aspect" , $ artifact , $ fileSpecification -> getSourcePlace ( ) ...
Adds an aspect from a file to the aspect kernel .
11,158
protected function _generateFiles ( ) { if ( $ this -> feature && ! $ this -> isSelectedFeature ( $ this -> feature ) ) { $ this -> logFile -> log ( null , "did not add aspect kernel because \"$this->feature\" is not selected" ) ; return ; } parent :: _generateFiles ( ) ; $ this -> files = array_merge ( $ this -> files...
Generates the aspect files and the aspect kernel .
11,159
protected function handleTransactionException ( $ e , $ currentAttempt , $ maxAttempts ) { if ( $ this -> causedByDeadlock ( $ e ) && $ this -> transactions > 1 ) { -- $ this -> transactions ; throw $ e ; } $ this -> rollBack ( ) ; if ( $ this -> causedByDeadlock ( $ e ) && $ currentAttempt < $ maxAttempts ) { return ;...
Handle an exception encountered when running a transacted statement .
11,160
protected function createTransaction ( ) { if ( $ this -> transactions === 0 ) { try { $ this -> getPdo ( ) -> beginTransaction ( ) ; } catch ( Exception $ e ) { $ this -> handleBeginTransactionException ( $ e ) ; } } elseif ( $ this -> transactions >= 1 && $ this -> queryGrammar -> supportsSavepoints ( ) ) { $ this ->...
Create a transaction within the database .
11,161
protected function performRollBack ( $ toLevel ) { if ( $ toLevel === 0 ) { $ this -> getPdo ( ) -> rollBack ( ) ; } elseif ( $ this -> queryGrammar -> supportsSavepoints ( ) ) { $ this -> getPdo ( ) -> exec ( $ this -> queryGrammar -> compileSavepointRollBack ( 'trans' . ( $ toLevel + 1 ) ) ) ; } }
Perform a rollback within the database .
11,162
public static function findPk ( $ pk ) { if ( empty ( $ pk ) ) { return false ; } if ( is_array ( $ pk ) ) { $ conditions = '' ; $ sep = '' ; foreach ( $ pk as $ name => $ value ) { $ conditions .= $ sep . "$name=:$name:" ; $ sep = ' AND ' ; } $ pk = array ( 'conditions' => $ conditions , 'bind' => $ pk ) ; } elseif ( ...
Finds model by primary key
11,163
public function isChanged ( ) { $ snapshot = $ this -> _snapshot ; if ( ! is_array ( $ snapshot ) ) { return true ; } $ metadata = $ this -> getModelsMetaData ( ) ; $ attrs = $ metadata -> getNonPrimaryKeyAttributes ( $ this ) ; $ automatic = $ metadata -> getAutomaticUpdateAttributes ( $ this ) ; $ bindDataTypes = $ m...
Checks whether the model changes
11,164
private function _make_hash ( ) : string { $ args = \ func_get_args ( ) ; if ( ( \ count ( $ args ) === 1 ) && \ is_array ( $ args [ 0 ] ) ) { $ args = $ args [ 0 ] ; } $ st = '' ; foreach ( $ args as $ a ) { $ st .= \ is_array ( $ a ) ? serialize ( $ a ) : '--' . $ a . '--' ; } return $ this -> hash_contour . md5 ( $ ...
Makes a string that will be the id of the request .
11,165
private function _trigger ( array $ cfg ) : array { if ( $ this -> triggers_disabled ) { $ cfg [ 'run' ] = 1 ; $ cfg [ 'trig' ] = 1 ; return $ cfg ; } if ( ! isset ( $ cfg [ 'trig' ] ) ) { $ cfg [ 'trig' ] = 1 ; } if ( ! isset ( $ cfg [ 'run' ] ) ) { $ cfg [ 'run' ] = 1 ; } if ( ! empty ( $ cfg [ 'tables' ] ) && ! empt...
Launches a function before or after
11,166
private function _add_primary ( array & $ cfg ) : void { if ( ! empty ( $ cfg [ 'primary' ] ) && empty ( $ cfg [ 'auto_increment' ] ) && ( ( $ idx = array_search ( $ cfg [ 'primary' ] , $ cfg [ 'fields' ] , true ) ) > - 1 ) && ( count ( $ cfg [ 'values' ] ) === ( count ( $ cfg [ 'fields' ] ) - 1 ) ) ) { $ val = false ;...
Adds a random primary value when it is absent from the set and present in the fields
11,167
public function retrieve_query ( string $ hash ) : ? array { if ( isset ( $ this -> queries [ $ hash ] ) ) { if ( \ is_string ( $ this -> queries [ $ hash ] ) ) { $ hash = $ this -> queries [ $ hash ] ; } return $ this -> queries [ $ hash ] ; } return null ; }
Retrieves a query array based on its hash .
11,168
public function filter_filters ( array $ cfg , $ field , $ operator = null ) : ? array { if ( isset ( $ cfg [ 'filters' ] ) ) { $ f = function ( $ cond , & $ res = [ ] ) use ( & $ f , $ field , $ operator ) { foreach ( $ cond as $ c ) { if ( isset ( $ c [ 'conditions' ] ) ) { $ f ( $ c [ 'conditions' ] , $ res ) ; } el...
Retrieve an array of specific filters among the existing ones .
11,169
public function error ( $ e ) : void { $ this -> has_error = true ; self :: has_error ( ) ; $ msg = [ self :: $ line , self :: get_log_line ( 'ERROR DB!' ) , self :: $ line ] ; if ( \ is_string ( $ e ) ) { $ msg [ ] = self :: get_log_line ( 'USER MESSAGE' ) ; $ msg [ ] = $ e ; } else if ( method_exists ( $ e , 'getMess...
Set an error and acts appropriately based oon the error mode
11,170
public function check ( ) : bool { if ( $ this -> current !== null ) { if ( $ this -> on_error === self :: E_CONTINUE ) { return true ; } if ( self :: $ has_error_all && ( $ this -> on_error !== self :: E_STOP_ALL ) ) { return false ; } if ( $ this -> has_error && ( $ this -> on_error !== self :: E_STOP ) ) { return fa...
Checks if the database is ready to process a query .
11,171
public function clear_cache ( $ item , $ mode ) : self { $ cache_name = $ this -> _cache_name ( $ item , $ mode ) ; if ( $ this -> cache_has ( $ cache_name ) ) { $ this -> cache_delete ( $ cache_name ) ; } return $ this ; }
Deletes a specific item from the cache .
11,172
public function stop_fancy_stuff ( ) : self { $ this -> setAttribute ( \ PDO :: ATTR_STATEMENT_CLASS , [ \ PDOStatement :: class ] ) ; $ this -> fancy = false ; return $ this ; }
Stops fancy stuff .
11,173
public function start_fancy_stuff ( ) : self { $ this -> setAttribute ( \ PDO :: ATTR_STATEMENT_CLASS , [ db \ query :: class , [ $ this ] ] ) ; $ this -> fancy = 1 ; return $ this ; }
Starts fancy stuff .
11,174
public function get_foreign_keys ( string $ col , string $ table , string $ db = null ) : array { if ( ! $ db ) { $ db = $ this -> current ; } $ res = [ ] ; $ model = $ this -> modelize ( ) ; foreach ( $ model as $ tn => $ m ) { foreach ( $ m [ 'keys' ] as $ k => $ t ) { if ( ( $ t [ 'ref_table' ] === $ table ) && ( $ ...
Return an array with tables and fields related to the searched foreign key .
11,175
public function has_id_increment ( $ table ) : bool { return ( $ model = $ this -> modelize ( $ table ) ) && isset ( $ model [ 'keys' ] [ 'PRIMARY' ] ) && ( \ count ( $ model [ 'keys' ] [ 'PRIMARY' ] [ 'columns' ] ) === 1 ) && ( $ model [ 'fields' ] [ $ model [ 'keys' ] [ 'PRIMARY' ] [ 'columns' ] [ 0 ] ] [ 'extra' ] =...
Return true if in the table there are fields with auto - increment . Working only on mysql .
11,176
public function modelize ( $ table = null , bool $ force = false ) : ? array { $ r = [ ] ; $ tables = false ; if ( empty ( $ table ) || $ table === '*' ) { $ tables = $ this -> get_tables ( $ this -> current ) ; } else if ( \ is_string ( $ table ) ) { $ tables = [ $ table ] ; } else if ( \ is_array ( $ table ) ) { $ ta...
Return the table s structure as an indexed array .
11,177
public function get_unique_primary ( $ table ) : ? string { if ( ( $ keys = $ this -> get_keys ( $ table ) ) && isset ( $ keys [ 'keys' ] [ 'PRIMARY' ] ) && ( \ count ( $ keys [ 'keys' ] [ 'PRIMARY' ] [ 'columns' ] ) === 1 ) ) { return $ keys [ 'keys' ] [ 'PRIMARY' ] [ 'columns' ] [ 0 ] ; } return null ; }
Return the unique primary key of the given table .
11,178
public function get_unique_keys ( $ table ) : array { $ fields = [ [ ] ] ; if ( $ ks = $ this -> get_keys ( $ table ) ) { foreach ( $ ks [ 'keys' ] as $ k ) { if ( $ k [ 'unique' ] ) { $ fields [ ] = $ k [ 'columns' ] ; } } } return array_merge ( ... $ fields ) ; }
Return the unique keys of a table as a numeric array .
11,179
public function escape_value ( string $ value , $ esc = "'" ) : string { return str_replace ( '%' , '\\%' , $ esc === '"' ? str :: escape_dquotes ( $ value ) : str :: escape_squotes ( $ value ) ) ; }
Return a string with quotes and percent escaped .
11,180
public function parse_query ( string $ statement ) : ? array { if ( $ this -> parser === null ) { $ this -> parser = new \ PHPSQLParser \ PHPSQLParser ( ) ; } try { $ r = $ this -> parser -> parse ( $ statement ) ; if ( ! count ( $ r ) ) { return null ; } if ( isset ( $ r [ 'BRACKET' ] ) && ( \ count ( $ r ) === 1 ) ) ...
Parses a SQL query and return an array .
11,181
public function last_id ( ) { if ( $ this -> last_insert_id ) { return str :: is_buid ( $ this -> last_insert_id ) ? bin2hex ( $ this -> last_insert_id ) : $ this -> last_insert_id ; } return false ; }
Return the last inserted ID .
11,182
public function new_id ( $ table , int $ min = 1 ) { $ tab = $ this -> modelize ( $ table ) ; if ( \ count ( $ tab [ 'keys' ] [ 'PRIMARY' ] [ 'columns' ] ) !== 1 ) { die ( "Error! Unique numeric primary key doesn't exist" ) ; } if ( ( $ id_field = $ tab [ 'keys' ] [ 'PRIMARY' ] [ 'columns' ] [ 0 ] ) && ( $ maxlength = ...
Generate a new casual id based on the max number of characters of id s column structure in the given table
11,183
public function random_value ( $ col , $ table ) { $ val = null ; if ( ( $ tab = $ this -> modelize ( $ table ) ) && isset ( $ tab [ 'fields' ] [ $ col ] ) ) { foreach ( $ tab [ 'keys' ] as $ key => $ cfg ) { if ( $ cfg [ 'unique' ] && ! empty ( $ cfg [ 'ref_column' ] ) && ( \ count ( $ cfg [ 'columns' ] ) === 1 ) && (...
Returns a random value fitting the requested column s type
11,184
public function get_key_val ( ) : ? array { if ( $ r = $ this -> query ( ... \ func_get_args ( ) ) ) { if ( $ rows = $ r -> get_rows ( ) ) { return x :: index_by_first_val ( $ rows ) ; } return [ ] ; } return null ; }
Return an array indexed on the first field of the request . The value will be an array if the request has more than two fields .
11,185
public function select ( $ table , $ fields = [ ] , array $ where = [ ] , array $ order = [ ] , int $ start = 0 ) : ? \ stdClass { $ args = $ this -> _add_kind ( $ this -> _set_limit_1 ( \ func_get_args ( ) ) ) ; if ( $ r = $ this -> _exec ( ... $ args ) ) { return $ r -> get_object ( ) ; } return null ; }
Returns the first row resulting from the query as an object .
11,186
public function select_all ( $ table , $ fields = [ ] , array $ where = [ ] , array $ order = [ ] , int $ limit = 0 , int $ start = 0 ) : ? array { if ( $ r = $ this -> _exec ( ... $ this -> _add_kind ( \ func_get_args ( ) ) ) ) { return $ r -> get_objects ( ) ; } return null ; }
Return table s rows resulting from the query as an array of objects .
11,187
public function iselect ( $ table , $ fields = [ ] , array $ where = [ ] , array $ order = [ ] , int $ start = 0 ) : ? array { if ( $ r = $ this -> _exec ( ... $ this -> _add_kind ( $ this -> _set_limit_1 ( \ func_get_args ( ) ) ) ) ) { return $ r -> get_irow ( ) ; } return null ; }
Return the first row resulting from the query as a numeric array .
11,188
public function iselect_all ( $ table , $ fields = [ ] , array $ where = [ ] , array $ order = [ ] , int $ limit = 0 , int $ start = 0 ) : ? array { if ( $ r = $ this -> _exec ( ... $ this -> _add_kind ( \ func_get_args ( ) ) ) ) { return $ r -> get_irows ( ) ; } return null ; }
Return the searched rows as an array of numeric arrays .
11,189
public function rselect ( $ table , $ fields = [ ] , array $ where = [ ] , array $ order = [ ] , int $ start = 0 ) : ? array { if ( $ r = $ this -> _exec ( ... $ this -> _add_kind ( $ this -> _set_limit_1 ( \ func_get_args ( ) ) ) ) ) { return $ r -> get_row ( ) ; } return null ; }
Return the first row resulting from the query as an indexed array .
11,190
public function rselect_all ( $ table , $ fields = [ ] , array $ where = [ ] , array $ order = [ ] , $ limit = 0 , $ start = 0 ) : ? array { if ( $ r = $ this -> _exec ( ... $ this -> _add_kind ( \ func_get_args ( ) ) ) ) { if ( \ is_object ( $ r ) ) { return $ r -> get_rows ( ) ; } $ this -> log ( 'ERROR IN RSELECT_AL...
Return table s rows as an array of indexed arrays .
11,191
public function select_one ( $ table , $ field = null , array $ where = [ ] , array $ order = [ ] , int $ start = 0 ) { if ( $ r = $ this -> _exec ( ... $ this -> _add_kind ( $ this -> _set_limit_1 ( \ func_get_args ( ) ) ) ) ) { if ( \ is_object ( $ r ) ) { return ( $ a = $ r -> get_irow ( ) ) ? $ a [ 0 ] : false ; } ...
Return a single value
11,192
public function select_all_by_keys ( $ table , array $ fields = [ ] , array $ where = [ ] , array $ order = [ ] , int $ limit = 0 , int $ start = 0 ) : ? array { if ( $ rows = $ this -> rselect_all ( $ table , $ fields , $ where , $ order , $ limit , $ start ) ) { return x :: index_by_first_val ( $ rows ) ; } return $ ...
Return an array indexed on the first field of the request . The value will be an array if the request has more than two fields . Return the same value as get_key_val .
11,193
public function stat ( string $ table , string $ column , array $ where = [ ] , array $ order = [ ] ) : ? array { if ( $ this -> check ( ) ) { return $ this -> rselect_all ( [ 'tables' => [ $ table ] , 'fields' => [ $ column , 'num' => 'COUNT(*)' ] , 'where' => $ where , 'order' => $ order , 'group_by' => [ $ column ] ...
Return an array with the count of values corresponding to the where conditions .
11,194
public function get_field_values ( $ table , $ field = null , array $ where = [ ] , array $ order = [ ] ) { return $ this -> get_column_values ( $ table , $ field , $ where , $ order ) ; }
Return the unique values of a column of a table as a numeric indexed array .
11,195
public function count_field_values ( $ table , string $ field = null , array $ where = [ ] , array $ order = [ ] ) { if ( \ is_array ( $ table ) && \ is_array ( $ table [ 'fields' ] ) && count ( $ table [ 'fields' ] ) ) { $ args = $ table ; $ field = array_values ( $ table [ 'fields' ] ) [ 0 ] ; } else { $ args = [ 'ta...
Return a count of identical values in a field as array reporting a structure type num - val .
11,196
public function get_values_count ( $ table , string $ field = null , array $ where = [ ] , $ order ) : array { return $ this -> count_field_values ( $ table , $ field , $ where , $ order ) ; }
Return a string with the sql query to count equal values in a field of the table .
11,197
public function change ( string $ db ) : self { if ( $ this -> language -> change ( $ db ) ) { $ this -> current = $ db ; } return $ this ; }
Changes the database used to the given one .
11,198
public function table_full_name ( string $ table , bool $ escaped = false ) : ? string { return $ this -> language -> table_full_name ( $ table , $ escaped ) ; }
Return table s full name .
11,199
public function table_simple_name ( string $ table , bool $ escaped = false ) : ? string { return $ this -> language -> table_simple_name ( $ table , $ escaped ) ; }
Return table s simple name .