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 ) ) { return false ; } if ( empty ( $ password ) ) { $ password = [ 'pass_hash' => $ sender -> { $ sender -> passwordHashAttribute } ] ; } $ class = $ sender -> passwordHistoryClass ; if ( array_key_exists ( 'pass_hash' , $ password ) ) { return $ class :: addHash ( $ password [ 'pass_hash' ] , $ sender ) ; } if ( array_key_exists ( 'password' , $ password ) ) { return $ class :: add ( $ password [ 'password' ] , $ sender ) ; } return false ; }
|
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 -> passwordUsedMessage ) ; } }
|
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 ( 'notifications' ) ) ; }
|
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 ( 'breadcrumbs' , Breadcrumbs :: render ( 'notifications-' . $ type ) ) ; } }
|
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 ( 'breadcrumbs' , Breadcrumbs :: render ( 'notification-create' ) ) ; }
|
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_variables [ $ index ] ) ) return self :: $ uri_variables [ $ index ] ; if ( isset ( self :: $ uri [ $ index ] ) ) if ( $ regex == ".*" || preg_match ( "/^" . $ regex . "$/i" , self :: $ uri [ $ index ] ) ) return self :: $ uri [ $ index ] ; throw new InvalidRequestURIException ; }
|
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 ] ] = self :: $ uri [ $ var [ 0 ] ] ; self :: $ api_mode = $ api_mode ; }
|
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 :: $ arguments [ $ key ] ) ) return self :: $ arguments [ $ key ] ; throw new InvalidRequestArgumentException ; } return $ default ; }
|
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 ( ) ) == 0 || strlen ( $ this -> getName ( ) ) > 255 ) { throw new DbException ( "Invalid migration name '" . $ this -> getName ( ) . "'" ) ; } try { $ log -> info ( "Applying " . $ this -> getName ( ) ) ; if ( $ this -> apply ( $ db ) ) { $ log -> info ( "Applied migration " . $ this -> getName ( ) ) ; } else { $ log -> error ( "Could not apply migration '" . $ this -> getName ( ) . "': " . $ db -> lastError ( ) ) ; throw new DbException ( "Could not apply migration " . $ this -> getName ( ) ) ; } } catch ( DbException $ e ) { $ log -> error ( "Could not apply migration '" . $ this -> getName ( ) . "': " . $ e -> getMessage ( ) ) ; throw new DbException ( "Could not apply migration " . $ this -> getName ( ) , $ e ) ; } $ q = $ db -> prepare ( "INSERT INTO migrations SET name=?" ) ; $ q -> execute ( array ( $ 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 .= '/' . $ this -> branchesPath . '/' . $ version ; } elseif ( in_array ( $ version , $ this -> getTags ( ) ) ) { $ repositoryUrl .= '/' . $ this -> tagsPath . '/' . $ version ; } else { return false ; } return ProcessUtils :: escapeArgument ( $ 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 [ "ctype" ] . ( $ part [ "charset" ] ? "; charset = \"" . $ part [ "charset" ] . "\"" : "" ) . ( $ part [ "name" ] ? "; name = \"" . $ part [ "name" ] . "\"" : "" ) . ( empty ( $ part [ "encode" ] ) ? "" : "\nContent-Transfer-Encoding: " . $ part [ "encode" ] ) . ( empty ( $ part [ "contentid" ] ) ? "" : "\nContent-ID: " . $ part [ "contentid" ] ) . ( ( empty ( $ part [ "contentid" ] ) && ( $ part [ "name" ] ) ) ? "\nContent-Disposition: attachment; filename=\"" . $ part [ "name" ] . '"' : '' ) . "\n\n$message\n" ; }
|
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 -> clauses -> dropEnd ( 1 ) -> add ( $ clause ) ; return $ query ; }
|
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 -> clauses -> dropEnd ( 1 ) -> add ( $ clause ) ; return $ query ; }
|
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 -> clauses -> dropEnd ( 1 ) -> add ( $ clause ) ; return $ query ; }
|
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 self ; $ query -> clauses = $ this -> clauses -> dropEnd ( 1 ) -> add ( $ clause ) ; return $ query ; }
|
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 ) -> add ( $ clause ) ; return $ query ; }
|
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 \ OnMatchClause ( $ cypher ) ) ; return $ query ; }
|
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 -> name , - 1 ) === '/' ? substr ( $ this -> name , 0 , - 1 ) : $ this -> name ; } } return $ this -> ext ; } return false ; }
|
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 ( $ this -> name , - 1 ) == '/' ) { $ this -> name = substr ( $ this -> name , 0 , - 1 ) ; } chmod ( $ f , 0644 ) ; $ this -> file = $ f ; $ this -> path = getcwd ( ) ; } else { $ this -> error = 'Impossible to get the file ' . $ this -> path . $ this -> name ; } } catch ( Error $ e ) { $ this -> error = 'Impossible to get the file ' . $ this -> path . $ this -> name ; } chdir ( $ d ) ; } return $ this ; }
|
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 . '"' ) ; while ( ! feof ( $ handle ) ) { echo fread ( $ handle , 65536 ) ; } fclose ( $ handle ) ; } else { die ( 'Impossible to read the file ' . $ this -> name ) ; } } return $ this ; }
|
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 ( $ new_name !== false ) { if ( $ new_name === 0 ) { $ dest .= $ this -> name ; } if ( null !== $ _FILES ) { move_uploaded_file ( $ this -> file , $ dest ) ; $ this -> file = $ dest ; $ this -> uploaded = 1 ; } else { copy ( $ this -> file , $ dest ) ; } } return $ this ; }
|
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 , 20 ) . '...' ; } $ to = '"' . $ this -> organizer -> dname . '" <' . $ this -> organizer -> email . '>' ; $ mail = new \ sb \ Email ( $ to , $ subject , $ this -> summary , $ to ) ; $ attendee_emails = Array ( ) ; foreach ( $ this -> attendees as $ attendee ) { $ attendee_emails [ ] = '"' . $ attendee -> dname . '" <' . $ attendee -> email . '>' ; } $ mail -> cc = $ attendee_emails ; $ mail -> addIcalendarEvent ( $ this ) ; return $ mail -> send ( ) ; }
|
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 && preg_match ( '/<link\h+(.+?)\h*\/?>/i' , $ req [ 'body' ] , $ parts ) && preg_match ( '/rel\h*=\h*"pingback"/i' , $ parts [ 1 ] ) && preg_match ( '/href\h*=\h*"\h*(.+?)\h*"/i' , $ parts [ 1 ] , $ href ) ) $ found = $ href [ 1 ] ; } return $ 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' , $ fw -> get ( 'ENCODING' ) ) ; $ doc -> stricterrorchecking = FALSE ; $ doc -> recover = TRUE ; if ( $ req && @ $ doc -> loadhtml ( $ req [ 'body' ] ) ) { $ links = $ doc -> getelementsbytagname ( 'a' ) ; foreach ( $ links as $ link ) { $ permalink = $ link -> getattribute ( 'href' ) ; if ( $ permalink && $ found = $ this -> enabled ( $ permalink ) ) { $ req = $ web -> request ( $ found , array ( 'method' => 'POST' , 'header' => 'Content-Type: application/xml' , 'content' => xmlrpc_encode_request ( 'pingback.ping' , array ( $ source , $ permalink ) , array ( 'encoding' => $ fw -> get ( 'ENCODING' ) ) ) ) ) ; if ( $ req && $ req [ 'body' ] ) $ this -> log .= date ( 'r' ) . ' ' . $ permalink . ' [permalink:' . $ found . ']' . PHP_EOL . $ req [ 'body' ] . PHP_EOL ; } } } unset ( $ doc ) ; } }
|
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 = Web :: instance ( ) ; $ args = xmlrpc_decode_request ( $ fw -> get ( 'BODY' ) , $ method , $ charset ) ; $ options = array ( 'encoding' => $ charset ) ; if ( $ method == 'pingback.ping' && isset ( $ args [ 0 ] , $ args [ 1 ] ) ) { list ( $ source , $ permalink ) = $ args ; $ doc = new DOMDocument ( '1.0' , $ fw -> get ( 'ENCODING' ) ) ; $ parts = parse_url ( $ permalink ) ; if ( ( empty ( $ parts [ 'scheme' ] ) || $ parts [ 'host' ] == $ fw -> get ( 'HOST' ) ) && preg_match ( '/^' . preg_quote ( $ path , '/' ) . '/' . ( $ fw -> get ( 'CASELESS' ) ? 'i' : '' ) , $ parts [ 'path' ] ) && $ this -> enabled ( $ permalink ) ) { $ parts = parse_url ( $ source ) ; if ( ( empty ( $ parts [ 'scheme' ] ) || $ parts [ 'host' ] == $ fw -> get ( 'HOST' ) ) && ( $ req = $ web -> request ( $ source ) ) && $ doc -> loadhtml ( $ req [ 'body' ] ) ) { $ links = $ doc -> getelementsbytagname ( 'a' ) ; foreach ( $ links as $ link ) { if ( $ link -> getattribute ( 'href' ) == $ permalink ) { call_user_func_array ( $ func , array ( $ source , $ req [ 'body' ] ) ) ; die ( xmlrpc_encode_request ( NULL , $ source , $ options ) ) ; } } die ( xmlrpc_encode_request ( NULL , 0x11 , $ options ) ) ; } die ( xmlrpc_encode_request ( NULL , 0x10 , $ options ) ) ; } die ( xmlrpc_encode_request ( NULL , 0x21 , $ options ) ) ; } die ( xmlrpc_encode_request ( NULL , 0x31 , $ options ) ) ; }
|
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 ( ) , $ fileSpecification -> getTargetPlace ( ) ) ; $ this -> logFile -> log ( $ artifact , "added aspect at \"{$fileSpecification->getTarget()}\"" ) ; }
|
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 , $ this -> aspectKernel -> generateFiles ( $ this -> class , $ this -> target ) ) ; }
|
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 ; } throw $ e ; }
|
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 -> createSavepoint ( ) ; } }
|
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 ( $ pk instanceof Criteria ) { $ pk = $ pk -> getParams ( ) ; } return static :: findFirst ( $ pk ) ; }
|
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 = $ metadata -> getBindTypes ( $ this ) ; foreach ( $ attrs as $ name ) { if ( isset ( $ automatic [ $ name ] ) ) { continue ; } $ value = $ this -> readAttribute ( $ name ) ; $ snapshotValue = ArrayHelper :: fetch ( $ snapshot , $ name ) ; if ( $ value === null ) { if ( $ snapshotValue !== null ) { return true ; } } else { if ( $ snapshotValue === null ) { return true ; } $ bindType = ArrayHelper :: fetch ( $ bindDataTypes , $ name ) ; switch ( $ bindType ) { case Column :: TYPE_DATE : case Column :: TYPE_VARCHAR : case Column :: TYPE_DATETIME : case Column :: TYPE_CHAR : case Column :: TYPE_TEXT : case Column :: TYPE_VARCHAR : case Column :: TYPE_BIGINTEGER : if ( ( ( string ) $ value ) !== ( ( string ) $ snapshotValue ) ) { return true ; } break ; default : if ( $ value != $ snapshotValue ) { return true ; } } } } return false ; }
|
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 ( $ st ) . $ this -> hash_contour ; }
|
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' ] ) && ! empty ( $ this -> triggers [ $ cfg [ 'kind' ] ] [ $ cfg [ 'moment' ] ] ) ) { $ table = $ this -> tfn ( \ is_array ( $ cfg [ 'tables' ] ) ? current ( $ cfg [ 'tables' ] ) : $ cfg [ 'tables' ] ) ; if ( isset ( $ this -> triggers [ $ cfg [ 'kind' ] ] [ $ cfg [ 'moment' ] ] [ $ table ] ) ) { foreach ( $ this -> triggers [ $ cfg [ 'kind' ] ] [ $ cfg [ 'moment' ] ] [ $ table ] as $ i => $ f ) { if ( $ f && \ is_callable ( $ f ) ) { if ( ! ( $ tmp = $ f ( $ cfg ) ) ) { $ cfg [ 'run' ] = false ; $ cfg [ 'trig' ] = false ; } else { $ cfg = $ tmp ; } } } } } return $ cfg ; }
|
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 ; switch ( $ cfg [ 'primary_type' ] ) { case 'int' : $ val = random_int ( ceil ( 10 ** ( $ cfg [ 'primary_length' ] > 3 ? $ cfg [ 'primary_length' ] - 3 : 1 ) / 2 ) , ceil ( 10 ** ( $ cfg [ 'primary_length' ] > 3 ? $ cfg [ 'primary_length' ] : 1 ) / 2 ) ) ; break ; case 'binary' : if ( $ cfg [ 'primary_length' ] === 16 ) { x :: log ( $ cfg [ 'tables' ] , 'add_options' ) ; $ val = $ this -> get_uid ( ) ; x :: log ( $ val , 'add_options' ) ; } break ; } if ( $ val ) { array_splice ( $ cfg [ 'values' ] , $ idx , 0 , $ val ) ; $ this -> set_last_insert_id ( $ val ) ; x :: log ( [ 'v' => $ cfg [ 'values' ] , 'f' => $ cfg [ 'fields' ] ] , 'add_options' ) ; } } }
|
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 ) ; } else if ( ( $ c [ 'field' ] === $ field ) && ( ! $ operator || ( $ operator === $ c [ 'operator' ] ) ) ) { $ res [ ] = $ c ; } } return $ res ; } ; return isset ( $ cfg [ 'filters' ] [ 'conditions' ] ) ? $ f ( $ cfg [ 'filters' ] [ 'conditions' ] ) : [ ] ; } return null ; }
|
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 , 'getMessage' ) ) { $ msg [ ] = self :: get_log_line ( 'DB MESSAGE' ) ; $ msg [ ] = $ e -> getMessage ( ) ; } $ this -> last_error = end ( $ msg ) ; $ msg [ ] = self :: get_log_line ( 'QUERY' ) ; $ msg [ ] = $ this -> last ( ) ; if ( $ this -> last_params [ 'values' ] ) { $ msg [ ] = self :: get_log_line ( 'VALUES' ) ; foreach ( $ this -> last_params [ 'values' ] as $ v ) { if ( $ v === null ) { $ msg [ ] = 'NULL' ; } else if ( \ is_bool ( $ v ) ) { $ msg [ ] = $ v ? 'TRUE' : 'FALSE' ; } else if ( \ is_string ( $ v ) ) { $ msg [ ] = str :: is_buid ( $ v ) ? bin2hex ( $ v ) : str :: cut ( $ v , 30 ) ; } else { $ msg [ ] = $ v ; } } } $ msg [ ] = self :: get_log_line ( 'BACKTRACE' ) ; $ dbt = array_reverse ( debug_backtrace ( ) ) ; array_walk ( $ dbt , function ( $ a , $ i ) use ( & $ msg ) { $ msg [ ] = str_repeat ( ' ' , $ i ) . ( $ i ? '->' : '' ) . "{$a['function']} (" . basename ( dirname ( $ a [ 'file' ] ) ) . '/' . basename ( $ a [ 'file' ] ) . ":{$a['line']})" ; } ) ; $ this -> log ( implode ( PHP_EOL , $ msg ) ) ; if ( $ this -> on_error === self :: E_DIE ) { die ( \ defined ( 'BBN_IS_DEV' ) && BBN_IS_DEV ? '<pre>' . PHP_EOL . implode ( PHP_EOL , $ msg ) . PHP_EOL . '</pre>' : 'Database error' ) ; } }
|
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 false ; } return true ; } return false ; }
|
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 ) && ( $ t [ 'ref_column' ] === $ col ) && ( $ t [ 'ref_db' ] === $ db ) && ( \ count ( $ t [ 'columns' ] ) === 1 ) ) { if ( ! isset ( $ res [ $ tn ] ) ) { $ res [ $ tn ] = [ $ t [ 'columns' ] [ 0 ] ] ; } else { $ res [ $ tn ] [ ] = $ t [ 'columns' ] [ 0 ] ; } } } } return $ res ; }
|
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' ] === 'auto_increment' ) ; }
|
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 ) ) { $ tables = $ table ; } if ( \ is_array ( $ tables ) ) { foreach ( $ tables as $ t ) { $ full = $ this -> tfn ( $ t ) ; $ r [ $ full ] = $ this -> _get_cache ( $ full , 'columns' , $ force ) ; } if ( \ count ( $ r ) === 1 ) { return end ( $ r ) ; } return $ r ; } return null ; }
|
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 ) ) { return null ; } return $ r ; } catch ( \ Exception $ e ) { $ this -> log ( 'Impossible to parse the query ' . $ statement ) ; } return null ; }
|
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 = $ tab [ 'fields' ] [ $ id_field ] [ 'maxlength' ] ) && ( $ maxlength > 1 ) ) { $ max = ( 10 ** $ maxlength ) - 1 ; if ( $ max >= mt_getrandmax ( ) ) { $ max = mt_getrandmax ( ) ; } if ( ( $ max > $ min ) && ( $ table = $ this -> tfn ( $ table , true ) ) ) { $ i = 0 ; do { $ id = random_int ( $ min , $ max ) ; $ i ++ ; } while ( ( $ i < 100 ) && $ this -> select ( $ table , [ $ id_field ] , [ $ id_field => $ id ] ) ) ; return $ id ; } } return null ; }
|
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 ) && ( $ col === $ cfg [ 'columns' ] [ 0 ] ) ) { return ( $ num = $ this -> count ( $ cfg [ 'ref_column' ] ) ) ? $ this -> select_one ( [ 'tables' [ $ cfg [ 'ref_table' ] ] , 'fields' => [ $ cfg [ 'ref_column' ] ] , 'start' => random_int ( 0 , $ num - 1 ) ] ) : null ; } } switch ( $ tab [ 'fields' ] [ $ col ] [ 'type' ] ) { case 'int' : if ( ( $ tab [ 'fields' ] [ $ col ] [ 'maxlength' ] === 1 ) && ! $ tab [ 'fields' ] [ $ col ] [ 'signed' ] ) { $ val = microtime ( true ) % 2 === 0 ? 1 : 0 ; } else { $ max = 10 ** $ tab [ 'fields' ] [ $ col ] [ 'maxlength' ] - 1 ; if ( $ max > mt_getrandmax ( ) ) { $ max = mt_getrandmax ( ) ; } if ( $ tab [ 'fields' ] [ $ col ] [ 'signed' ] ) { $ max /= 2 ; } $ min = $ tab [ 'fields' ] [ $ col ] [ 'signed' ] ? - $ max : 0 ; $ val = random_int ( $ min , $ max ) ; } break ; case 'float' : case 'double' : case 'decimal' : break ; case 'varchar' : break ; case 'text' : break ; case 'date' : break ; case 'datetime' : break ; case 'timestamp' : break ; case 'time' : break ; case 'year' : break ; case 'blob' : break ; case 'binary' : break ; case 'varbinary' : break ; case 'enum' : break ; } } return $ val ; }
|
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_ALL' , $ r ) ; } return [ ] ; }
|
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 ; } $ this -> log ( 'ERROR IN RSELECT_ONE' , $ r ) ; } return 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 $ this -> check ( ) ? [ ] : 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 . 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 null ; }
|
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 = [ 'tables' => [ $ table ] , 'where' => $ where , 'order' => $ order ] ; } $ args = array_merge ( $ args , [ 'kind' => 'SELECT' , 'fields' => [ 'val' => $ field , 'num' => 'COUNT(*)' ] , 'group_by' => [ $ field ] ] ) ; return $ this -> rselect_all ( $ args ) ; }
|
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 .
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.