PHP Classes

File: lib/pdooneorm

Recommend this page to a friend!
  Packages of Jorge Castro   PDO One ORM   lib/pdooneorm   Download  
File: lib/pdooneorm
Role: Example script
Content type: text/plain
Description: Example script
Class: PDO One ORM
Access SQL database tables as object using PDO
Author: By
Last change:
Date: 3 years ago
Size: 1,174 bytes
 

 

Contents

Class file image Download
<?php

namespace eftec;

function findVendorPath(?string $initPath = null): string
    {
        $initPath = $initPath ?: __DIR__;
        $prefix = '';
        $defaultvendor = $initPath;
        // finding vendor
        for ($i = 0; $i < 8; $i++) {
            if (@file_exists("$initPath/{$prefix}vendor/autoload.php")) {
                $defaultvendor = "{$prefix}vendor";
                break;
            }
            $prefix .= '../';
        }
        return $defaultvendor;
    }

    include_once __DIR__ . '/' . findVendorPath() . '/autoload.php';


include_once __DIR__ . '/PdoOneORMCli.php';
// this code only runs on CLI but only if pdooneormcli.php is called directly and via command line.
if (!defined('PHPUNIT_COMPOSER_INSTALL') && !defined('__PHPUNIT_PHAR__')
    && isset($_SERVER['PHP_SELF']) &&
    PdoOneORMCli::isCli() &&
    (basename($_SERVER['PHP_SELF']) === 'pdooneorm.php' || basename($_SERVER['PHP_SELF']) === 'pdooneorm')
) {
    // we also excluded it if it is called by phpunit.
    $path = PdoOneORMCli::findVendorPath();


    $cli = new PdoOneORMCli();
    /** @noinspection PhpUnhandledExceptionInspection */
    $cli->cliEngine();
}