PHP Classes

File: lib/template/template_base.php

Recommend this page to a friend!
  Classes of Jorge Castro   PDO One ORM   lib/template/template_base.php   Download  
File: lib/template/template_base.php
Role: Auxiliary script
Content type: text/plain
Description: Auxiliary script
Class: PDO One ORM
Access SQL database tables as object using PDO
Author: By
Last change:
Date: 1 year ago
Size: 4,157 bytes
 

Contents

Class file image Download
<?php http_response_code(404); die(1); // It is a template file, not a code to execute directly. This line is used to avoid to execute or read it. ?>
/** @noinspection PhpMissingParamTypeInspection
 * @noinspection PhpMissingReturnTypeInspection
 * @noinspection PhpMissingFieldTypeInspection
 * @noinspection UnknownInspectionInspection
 * @noinspection AccessModifierPresentedInspection
 * @noinspection PhpIncompatibleReturnTypeInspection
 * @noinspection ReturnTypeCanBeDeclaredInspection
 * @noinspection DuplicatedCode
 * @noinspection PhpUnused
 * @noinspection PhpUndefinedMethodInspection
 * @noinspection PhpUnusedLocalVariableInspection
 * @noinspection PhpUnusedAliasInspection
 * @noinspection NullPointerExceptionInspection
 * @noinspection SenselessProxyMethodInspection
 * @noinspection PhpParameterByRefIsNotUsedAsReferenceInspection
 */
{namespace}
use eftec\PdoOne;
use eftec\_BasePdoOneRepo;use eftec\PdoOneQuery;
{exception}
// [EDIT:use] you can edit this part
// Here you can add your custom use
// [/EDIT] end of edit

/**
 * Class {class}. Copyright (c) Jorge Castro C. (https://github.com/EFTEC/PdoOne)<br>
 * <b>DO NOT EDIT THE CODE OUTSIDE EDIT BLOCKS</b>. This code is generated<br>
 * Generated by PdoOne Version {version}.
 */
class {class} extends _BasePdoOneRepo
{
    const type = '{type}';
    const COMPILEDVERSION={compiled};
    const NS = '{namespace2}';

    /**
     * @var bool if true then it uses objects (instead of array) in the
     * methods tolist(),first(),insert(),update() and delete()
     */
    public static $useModel={modeluse};


    /** @var string[] it is used to set the relations betweeen table (key) and class (value) */
    const RELATIONS = {relations};
    /** @var PdoOne */
    public static $pdoOne;
    /** @var string|null $schema the current schema/database */
    public static $schema;
    /** @var PdoOneQuery */
    public static $pdoOneQuery;
    /** @var array $gQuery =[['columns'=>[],'joins'=>[],'where'=>[]] */
    public static $gQuery = [];
    public static $gQueryCounter = 0;
    public static $pageSize = 20;
    public static $lastException = '';
    /** @var bool if true then it returns a false on error. If false, it throws an exception in case of error */
    protected static $falseOnError = false;

    /** @var null|string the unique id generate by sha256 and based in the query, arguments, type and methods */
    protected static $uid;

    /**
     * With the name of the table, we get the class
     * @param string $tableName
     *
     * @return string[]
     */
    protected function tabletoClass(string $tableName) {
        return static::RELATIONS[$tableName];
    }

    /**
     * It sets the field self::$pdoOne
     *
     * @param $pdoOne
     */
    public static function setPdoOne($pdoOne)
    {
        static::$pdoOne = $pdoOne;
    }
    /**
     * It is used for DI.<br>
     * If the field is not null, it returns the field self::$pdoOne<br>
     * If the global function pdoOne exists, then it is used<br>
     * if the global variable $pdoOne exists, then it is used<br>
     * Otherwise, it returns null
     *
     * @return PdoOne
     */
    protected static function getPdoOne()
    {
        if (self::$pdoOne !== null) {
            return self::$pdoOne;
        }
        if (self::BINARYVERSION !== static::COMPILEDVERSION) {
            $p = new PdoOne('test', 'no database', '', '');
            $p->throwError('Repository classes requires a new version. Please update PdoOne and rebuild'
                , self::class);
        }

        if(PdoOne::instance(false)!==null) {
            self::$pdoOne=PdoOne::instance(false);
            return self::$pdoOne;
        }

        if (function_exists('PdoOne')) {
            self::$pdoOne = PdoOne();
            return self::$pdoOne;
        }
        if (isset($GLOBALS['pdoOne']) && $GLOBALS['pdoOne'] instanceof PdoOne) {
            self::$pdoOne = $GLOBALS['pdoOne'];
            return self::$pdoOne;
        }
        return self::$pdoOne;
    }
    // [EDIT:content] you can edit this part
    // Here you can add your custom content.
    // [/EDIT] end of edit
}