Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
dp-ifacesoft committed Sep 29, 2020
1 parent 16ba579 commit d87cf66
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 23 deletions.
18 changes: 14 additions & 4 deletions source/Ice/Core/Environment.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down Expand Up @@ -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)
{
Expand All @@ -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
Expand Down Expand Up @@ -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) {
Expand Down
8 changes: 4 additions & 4 deletions source/Ice/Core/QueryTranslator.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

namespace Ice\Core;

use Ice\Core;
use Ice\Exception\DataSource as Exception_DataSource;

/**
Expand All @@ -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]>
*
Expand All @@ -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
Expand Down
9 changes: 5 additions & 4 deletions source/Ice/DataProvider/Cli.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

use Ice\Core\Action;
use Ice\Core\DataProvider;
use Ice\Core\Exception;
use Ice\Exception\Error;

/**
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
27 changes: 16 additions & 11 deletions source/Ice/QueryTranslator/Sql.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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();
Expand Down Expand Up @@ -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 '';
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit d87cf66

Please sign in to comment.