-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
dp-ifacesoft
committed
Sep 29, 2020
1 parent
16ba579
commit d87cf66
Showing
4 changed files
with
39 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,8 @@ | |
|
||
use Ice\Core; | ||
use Ice\Exception\Access_Denied_Environment; | ||
use Ice\Exception\Config_Error; | ||
use Ice\Exception\FileNotFound; | ||
use Ice\Helper\Type_String; | ||
|
||
/** | ||
|
@@ -43,8 +45,8 @@ public static function isLoaded() | |
* @param $message | ||
* @throws Access_Denied_Environment | ||
* @throws Exception | ||
* @throws \Ice\Exception\Config_Error | ||
* @throws \Ice\Exception\FileNotFound | ||
* @throws Config_Error | ||
* @throws FileNotFound | ||
*/ | ||
public static function checkAccess($environments, $message) | ||
{ | ||
|
@@ -65,8 +67,8 @@ public static function checkAccess($environments, $message) | |
* @param array $selfConfig | ||
* @return Environment|Config | ||
* @throws Exception | ||
* @throws \Ice\Exception\Config_Error | ||
* @throws \Ice\Exception\FileNotFound | ||
* @throws Config_Error | ||
* @throws FileNotFound | ||
* @author dp <[email protected]> | ||
* | ||
* @version 0.5 | ||
|
@@ -98,6 +100,14 @@ public static function getInstance( | |
} | ||
} | ||
|
||
if ($environmentName !== self::PRODUCTION && !empty($_SERVER['argv'])) { | ||
foreach ($_SERVER['argv'] as $arg) { | ||
if ($pos = strpos($arg, 'iceEnv') !== false) { | ||
$environmentName = substr($arg, 7); | ||
} | ||
} | ||
} | ||
|
||
$environment = []; | ||
|
||
foreach ($config->gets() as $name => $env) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ | |
|
||
namespace Ice\Core; | ||
|
||
use Ice\Core; | ||
use Ice\Exception\DataSource as Exception_DataSource; | ||
|
||
/** | ||
|
@@ -33,7 +34,7 @@ abstract class QueryTranslator extends Container | |
* @param null $instanceKey | ||
* @param null $ttl | ||
* @param array $params | ||
* @return \Ice\Core|Container | ||
* @return Core|Container | ||
* | ||
* @author dp <[email protected]> | ||
* | ||
|
@@ -49,11 +50,10 @@ public static function getInstance($instanceKey = null, $ttl = null, array $para | |
/** | ||
* Translate query body | ||
* | ||
* @param array $sqlParts | ||
* @param $modelClassTableAlias | ||
* @param Query $query | ||
* @param DataSource $dataSource | ||
* @return string|array | ||
* @throws Exception | ||
* @throws Exception_DataSource | ||
* @author dp <[email protected]> | ||
* | ||
* @version 0.4 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ | |
|
||
use Ice\Core\Action; | ||
use Ice\Core\DataProvider; | ||
use Ice\Core\Exception; | ||
use Ice\Exception\Error; | ||
|
||
/** | ||
|
@@ -47,12 +48,12 @@ protected static function getDefaultKey() | |
/** | ||
* Get data from data provider by key | ||
* | ||
* @param string $key | ||
* @param null $key | ||
* @param null $default | ||
* @param bool $require | ||
* @return mixed | ||
* @throws Error | ||
* @throws \Ice\Core\Exception | ||
* @throws Exception | ||
* @author dp <[email protected]> | ||
* | ||
* @version 1.2 | ||
|
@@ -80,11 +81,11 @@ public function get($key = null, $default = null, $require = false) | |
/** | ||
* Set data to data provider | ||
* | ||
* @param array $values | ||
* @param array|null $values | ||
* @param null $ttl | ||
* @return array | ||
* | ||
* @throws \Ice\Core\Exception | ||
* @throws Exception | ||
* @author dp <[email protected]> | ||
* | ||
* @version 1.2 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -86,10 +86,11 @@ public function translateDrop(Query $query, DataSource $dataSource) | |
/** | ||
* Translate set part | ||
* | ||
* @param array $part | ||
* @param $modelClassTableAlias | ||
* @param Query $query | ||
* @param DataSource $dataSource | ||
* @return string | ||
* | ||
* @throws Exception | ||
* @author dp <[email protected]> | ||
* | ||
* @version 1.13 | ||
|
@@ -105,7 +106,7 @@ protected function translateSet(Query $query, DataSource $dataSource) | |
|
||
if ($part['rowCount'] > 1) { | ||
$part['_update'] = true; | ||
return $this->translateValues($part, $modelClassTableAlias); | ||
return $this->translateValues($query, $dataSource, $part); | ||
} | ||
|
||
$modelClass = $query->getQueryBuilder()->getModelClass(); | ||
|
@@ -151,21 +152,25 @@ function ($fieldName) use ($modelScheme, $fieldColumnMap, $tableAlias) { | |
/** | ||
* Translate values part | ||
* | ||
* @param array $part | ||
* @param $modelClassTableAlias | ||
* @param Query $query | ||
* @param DataSource $dataSource | ||
* @param null $updatePart | ||
* @return string | ||
* | ||
* @throws Exception | ||
* @author dp <[email protected]> | ||
* | ||
* @version 1.13 | ||
* @since 0.0 | ||
*/ | ||
protected function translateValues(Query $query, DataSource $dataSource) | ||
protected function translateValues(Query $query, DataSource $dataSource, $updatePart = null) | ||
{ | ||
$part = $query->getQueryBuilder()->getSqlParts(strtolower(substr(__FUNCTION__, strlen('translate')))); | ||
$part = $updatePart | ||
? $updatePart | ||
: $query->getQueryBuilder()->getSqlParts(strtolower(substr(__FUNCTION__, strlen('translate')))); | ||
|
||
$update = $part['_update']; | ||
unset($part['_update']); | ||
$update = $part['_update']; | ||
unset($part['_update']); | ||
|
||
if (!$part) { | ||
return ''; | ||
|
@@ -528,7 +533,7 @@ protected function translateSelect(Query $query, DataSource $dataSource) | |
$sql .= "\n" . Sql::SQL_STATEMENT_SELECT . ($distinct ? ' ' . Sql::SQL_DISTINCT . ' ' : '') . ($calcFoundRows ? ' ' . Sql::SQL_CALC_FOUND_ROWS . ' ' : '') . ($sqlNoCache ? ' ' . Sql::SQL_SQL_NO_CACHE . ' ' : '') . | ||
"\n\t" . implode(',' . "\n\t", $fields) . | ||
"\n" . Sql::SQL_CLAUSE_FROM . | ||
"\n" . '('. implode( | ||
"\n" . '(' . implode( | ||
"\n" . Sql::SQL_CLAUSE_UNION . "\n", | ||
array_map( | ||
function ($query) use ($dataSource) { | ||
|
@@ -619,7 +624,7 @@ protected function translateJoin(Query $query, DataSource $dataSource) | |
} | ||
|
||
foreach ($part as $tableAlias => $joinTable) { | ||
/** @var Model $joinModelClass */ | ||
/** @var Model $joinModelClass */ | ||
$joinModelClass = $joinTable['class']; | ||
|
||
if ($joinModelClass instanceof QueryBuilder) { | ||
|