PHP Classes

File: examples/sqlsrv/autoload.php

Recommend this page to a friend!
  Classes of Jorge Castro   PHP PDO One   examples/sqlsrv/autoload.php   Download  
File: examples/sqlsrv/autoload.php
Role: Example script
Content type: text/plain
Description: Example script
Class: PHP PDO One
Access to database with PDO and run common queries
Author: By
Last change:
Date: 19 days ago
Size: 3,531 bytes
 

Contents

Class file image Download
<?php
/**
 * This class is used for autocomplete.
 * Class _AUTOLOAD_
 * @noautoload it avoids to index this class
 * @generated by AutoLoadOne 1.19.2 generated 2020/07/19 12:10:12
 * @copyright Copyright Jorge Castro C - MIT License. https://github.com/EFTEC/AutoLoadOne
 */
$s5f147064bc563__debug = true;

/* @var string[] Where $_arrautoloadCustom['namespace\Class']='folder\file.php' */
$s5f147064bc563__arrautoloadCustom = [

];
$s5f147064bc563__arrautoloadCustomCommon = [

];

/* @var string[] Where $_arrautoload['namespace']='folder' */
$s5f147064bc563__arrautoload = [
   
'reposqlsrv' => '|1|',
   
'sqlsrv\repomodel' => '|1|model'
];
$s5f147064bc563__arrautoloadCommon = [
   
1 => '/../reposqlsrv/generated'
];

/* @var boolean[] Where $_arrautoload['namespace' or 'namespace\Class']=true if it's absolute (it uses the full path) */
$s5f147064bc563__arrautoloadAbsolute = [
 
];

/**
 * @param $class_name
 * @throws Exception
 */
function s5f147064bc563__auto($class_name)
{
   
// its called only if the class is not loaded.
   
$ns = dirname($class_name); // without trailing
   
$ns = ($ns === '.') ? '' : $ns;
   
$cls = basename($class_name);
   
// special cases
   
if (isset($GLOBALS['s5f147064bc563__arrautoloadCustom'][$class_name])) {
       
s5f147064bc563__loadIfExists($GLOBALS['s5f147064bc563__arrautoloadCustom'][$class_name]
            ,
$class_name,'s5f147064bc563__arrautoloadCustomCommon');
        return;
    }
   
// normal (folder) cases
   
if (isset($GLOBALS['s5f147064bc563__arrautoload'][$ns])) {
       
s5f147064bc563__loadIfExists($GLOBALS['s5f147064bc563__arrautoload'][$ns] . '/' . $cls . '.php'
           
, $ns,'s5f147064bc563__arrautoloadCommon');
        return;
    }
}

/**
 * We load the file.
 * @param string $filename
 * @param string $key key of the class it could be the full class name or only the namespace
 * @param string $arrayName [optional] it's the name of the arrayname used to replaced |n| values.
 * @throws Exception
 */
function s5f147064bc563__loadIfExists($filename, $key,$arrayName='')
{
    if (isset(
$GLOBALS['s5f147064bc563__arrautoloadAbsolute'][$key])) {
       
$fullFile = $filename; // its an absolute path
       
if (strpos($fullFile, '../') === 0) { // Or maybe, not, it's a remote-relative path.
           
$oldDir = getcwd(); // we copy the current url
           
chdir(__DIR__);
        }
    } else {
       
$fullFile = __DIR__ . '/' . s5f147064bc563__replaceCurlyVariable($filename, $arrayName); // its relative to this path
   
}
   
/** @noinspection PhpIncludeInspection */
   
if ((@include $fullFile) === false) {
        if (
$GLOBALS['s5f147064bc563__debug']) {
            throw new
RuntimeException('AutoLoadOne Error: Loading file [' . __DIR__ . '/' . $filename . '] for class [' . basename($filename) .
                                
']');
        }
        throw new
RuntimeException('AutoLoadOne Error: No file found.');
    }
    if (isset(
$oldDir)) {
       
chdir($oldDir);
    }
}
function
s5f147064bc563__replaceCurlyVariable($string,$arrayName) {
    if(
strpos($string,'|')===false) {
        return
$string;
    }
// nothing to replace.
   
return preg_replace_callback('/\\|\s?(\w+)\s?\\|/u', static function ($matches) use ($arrayName) {
       
$item = is_array($matches) ? substr($matches[0], 1, -1)
            :
substr($matches, 1, -1);
        return
$GLOBALS[$arrayName][$item];
    },
$string);
}

spl_autoload_register(static function ($class_name) {
   
s5f147064bc563__auto($class_name);
});
// autorun