From c218ac3e3ae1ee5d20bbc4b05026be8f9a7a3ca9 Mon Sep 17 00:00:00 2001 From: dp-ifacesoft Date: Tue, 4 Aug 2020 16:45:41 +0300 Subject: [PATCH] fixes --- source/Ice/Core/Loader.php | 119 +++++++++++++++-------------- source/Ice/Core/QueryBuilder.php | 7 +- source/Ice/QueryTranslator/Sql.php | 2 +- 3 files changed, 65 insertions(+), 63 deletions(-) diff --git a/source/Ice/Core/Loader.php b/source/Ice/Core/Loader.php index 96c3e5b6..d6f283c7 100644 --- a/source/Ice/Core/Loader.php +++ b/source/Ice/Core/Loader.php @@ -12,6 +12,7 @@ use Composer\Autoload\ClassLoader; use Ice\Core; use Ice\DataProvider\Repository; +use Ice\Exception\Config_Error; use Ice\Exception\FileNotFound; use Ice\Helper\Class_Object; @@ -60,75 +61,21 @@ public static function autoload($class) return null; } - public static function isExistsClass($class) - { - return class_exists($class, false) || interface_exists($class, false) || trait_exists($class, false); - } - - /** - * Load class - * - * @param $class - * @return bool - * @throws Exception - * @author dp - * - * @version 1.10 - * @since 0.0 - */ - public static function load($class) - { - if (class_exists($class, false)) { - return true; - } - - if (Loader::$repository) { - if ($fileName = Loader::$repository->get($class)) { - include_once $fileName; - return true; - } - } - - foreach (Loader::$autoloaders as $autoLoader) { - $fileName = null; - if ($autoLoader[0] instanceof ClassLoader) { - if ($fileName = $autoLoader[0]->findFile($class)) { - include_once $fileName; - } - } else { - $fileName = call_user_func($autoLoader, $class); - } - - if (is_string($fileName) && !empty($fileName) && Loader::isExistsClass($class)) { - if (Loader::$repository) { - Loader::$repository->set([$class => $fileName]); - } - - return true; - } - } - - // todo: раскомментить -// Logger::getInstance(__CLASS__)->warning(['Class {$0} not found', $class], __FILE__, __LINE__, null); - - return false; - } - /** * Return class path * * @param $class * @param $ext * @param $path - * @param bool $isRequired - * @param bool $isNotEmpty - * @param bool $isOnlyFirst - * @param bool $allMatchedPathes + * @param bool $isRequired + * @param bool $isNotEmpty + * @param bool $isOnlyFirst + * @param bool $allMatchedPathes * @return null|string * * @throws Exception * @throws FileNotFound - * @throws \Ice\Exception\Config_Error + * @throws Config_Error * @author dp * * @version 0.0 @@ -200,6 +147,60 @@ public static function getFilePath( return $isNotEmpty && !empty($fullStackPathes) ? reset($fullStackPathes) : ''; } + public static function isExistsClass($class) + { + return class_exists($class, false) || interface_exists($class, false) || trait_exists($class, false); + } + + /** + * Load class + * + * @param $class + * @return bool + * @author dp + * + * @version 1.10 + * @since 0.0 + */ + public static function load($class) + { + if (class_exists($class, false)) { + return true; + } + + if (Loader::$repository) { + if ($fileName = Loader::$repository->get($class)) { + include_once $fileName; + return true; + } + } + + foreach (Loader::$autoloaders as $autoLoader) { + $fileName = null; + + if (is_array($autoLoader) && $autoLoader[0] instanceof ClassLoader) { // old composer + if ($fileName = $autoLoader[0]->findFile($class)) { + include_once $fileName; + } + } else { + $fileName = call_user_func($autoLoader, $class); + } + + if (is_string($fileName) && !empty($fileName) && Loader::isExistsClass($class)) { + if (Loader::$repository) { + Loader::$repository->set([$class => $fileName]); + } + + return true; + } + } + + // todo: раскомментить +// Logger::getInstance(__CLASS__)->warning(['Class {$0} not found', $class], __FILE__, __LINE__, null); + + return false; + } + public static function init() { self::$autoloaders = spl_autoload_functions(); diff --git a/source/Ice/Core/QueryBuilder.php b/source/Ice/Core/QueryBuilder.php index e3158a15..7acdcc22 100644 --- a/source/Ice/Core/QueryBuilder.php +++ b/source/Ice/Core/QueryBuilder.php @@ -992,7 +992,7 @@ public function rlike($fieldName, $value, $modelTableData = [], $sqlLogical = Qu * Set inner join query part * * @param $modelTableData - * @param string|array $fieldNames + * @param null $fieldNames * @param null $condition * @param bool $isUse * @return QueryBuilder @@ -1000,7 +1000,6 @@ public function rlike($fieldName, $value, $modelTableData = [], $sqlLogical = Qu * @version 1.5 * @since 0.0 * @author dp - * */ public function inner($modelTableData, $fieldNames = null, $condition = null, $isUse = true) { @@ -2418,10 +2417,12 @@ public function getWidgets() /** * @param $funcName - * @param argumentString + * @param $argumentString * @param array $modelTableData * @return $this * @throws Exception + * + * @todo feature using: ->func('fieldAlias', 'funcName', 'funcArgument', $modelTableData) */ public function func($funcName, $argumentString, $modelTableData = []) { diff --git a/source/Ice/QueryTranslator/Sql.php b/source/Ice/QueryTranslator/Sql.php index bad59cc3..ec274d2a 100644 --- a/source/Ice/QueryTranslator/Sql.php +++ b/source/Ice/QueryTranslator/Sql.php @@ -43,7 +43,7 @@ class Sql extends QueryTranslator const SQL_STATEMENT_UPDATE = 'UPDATE'; const SQL_STATEMENT_DELETE = 'DELETE'; const SQL_CLAUSE_FROM = 'FROM'; - const SQL_CLAUSE_UNION = 'UNION'; + const SQL_CLAUSE_UNION = 'UNION ALL'; const SQL_CLAUSE_INTO = 'INTO'; const SQL_CLAUSE_SET = 'SET'; const SQL_CLAUSE_VALUES = 'VALUES';