Skip to content

Commit

Permalink
Merge branch 'dp' into 1.24
Browse files Browse the repository at this point in the history
  • Loading branch information
dp-ifacesoft committed Aug 20, 2020
2 parents c7a13ac + 0d85e2f commit 2bc05f0
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 86 deletions.
175 changes: 89 additions & 86 deletions source/Ice/Core/QueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,81 @@ public function getModelClass()
return $this->modelClass;
}

/**
* Return table alias for model class for query
*
* @return Model|string
*
* @author dp <[email protected]>
*
* @version 0.0
* @since 0.0
*/
public function getTableAlias()
{
return $this->tableAlias;
}

/**
* Set in query part where expression 'in (?)'
*
* @param $fieldName
* @param array $fieldValue
* @param array $modelTableData
* @param string $sqlLogical
* @param bool $isUse
* @return QueryBuilder
* @throws Exception
* @author dp <[email protected]>
*
* @version 1.13
* @since 0.0
*/
public function in($fieldName, $fieldValue, $modelTableData = [], $sqlLogical = QueryBuilder::SQL_LOGICAL_AND, $isUse = true)
{
if (empty($fieldValue)) {
$fieldValue = [0];
}

return $this->where(
[$fieldName => $fieldValue],
$modelTableData,
QueryBuilder::SQL_COMPARISON_KEYWORD_IN,
$sqlLogical,
$isUse
);
}

/**
* Set in query part where expression 'not in (?)'
*
* @param $fieldName
* @param array $fieldValue
* @param array $modelTableData
* @param string $sqlLogical
* @param bool $isUse
* @return QueryBuilder
* @throws Exception
* @author dp <[email protected]>
*
* @version 1.3
* @since 0.0
*/
public function notIn($fieldName, array $fieldValue, $modelTableData = [], $sqlLogical = QueryBuilder::SQL_LOGICAL_AND, $isUse = true)
{
if (empty($fieldValue)) {
$fieldValue = [0];
}

return $this->where(
[$fieldName => $fieldValue],
$modelTableData,
QueryBuilder::SQL_COMPARISON_KEYWORD_NOT_IN,
$sqlLogical,
$isUse
);
}

/**
* Append cache validate or invalidate tags for this query builder
*
Expand Down Expand Up @@ -837,36 +912,6 @@ public function ne($fieldName, $fieldValue, $modelTableData = [], $sqlLogical =
);
}

/**
* Set in query part where expression 'not in (?)'
*
* @param $fieldName
* @param array $fieldValue
* @param array $modelTableData
* @param string $sqlLogical
* @param bool $isUse
* @return QueryBuilder
* @throws Exception
* @author dp <[email protected]>
*
* @version 1.3
* @since 0.0
*/
public function notIn($fieldName, array $fieldValue, $modelTableData = [], $sqlLogical = QueryBuilder::SQL_LOGICAL_AND, $isUse = true)
{
if (empty($fieldValue)) {
$fieldValue = [0];
}

return $this->where(
[$fieldName => $fieldValue],
$modelTableData,
QueryBuilder::SQL_COMPARISON_KEYWORD_NOT_IN,
$sqlLogical,
$isUse
);
}

/**
* Set in query part where expression '== 1' is boolean true(1)
*
Expand Down Expand Up @@ -1105,21 +1150,6 @@ private function join($joinType, $modelTableData, $condition = null)
return $this;
}

/**
* Return table alias for model class for query
*
* @return Model|string
*
* @author dp <[email protected]>
*
* @version 0.0
* @since 0.0
*/
public function getTableAlias()
{
return $this->tableAlias;
}

/**
* @param $joinType
* @param Model $modelTableData
Expand Down Expand Up @@ -1311,6 +1341,11 @@ private function addJoin($joinType, $modelTableData, array $joins)
return false;
}

public function getBindParts()
{
return $this->bindParts;
}

/**
* Prepare select query part
*
Expand Down Expand Up @@ -1420,11 +1455,6 @@ public function select($fieldName, $fieldAlias = null, $modelTableData = [], $is
return $this;
}

public function getBindParts()
{
return $this->bindParts;
}

/**
* Return query result for select query
*
Expand Down Expand Up @@ -1753,36 +1783,6 @@ public function inPk(array $value, $modelTableData = [], $sqlLogical = QueryBuil
return $this->in(reset($pkFieldNames), $value, $modelTableData, $sqlLogical);
}

/**
* Set in query part where expression 'in (?)'
*
* @param $fieldName
* @param array $fieldValue
* @param array $modelTableData
* @param string $sqlLogical
* @param bool $isUse
* @return QueryBuilder
* @throws Exception
* @author dp <[email protected]>
*
* @version 1.13
* @since 0.0
*/
public function in($fieldName, $fieldValue, $modelTableData = [], $sqlLogical = QueryBuilder::SQL_LOGICAL_AND, $isUse = true)
{
if (empty($fieldValue)) {
$fieldValue = [0];
}

return $this->where(
[$fieldName => $fieldValue],
$modelTableData,
QueryBuilder::SQL_COMPARISON_KEYWORD_IN,
$sqlLogical,
$isUse
);
}

/**
* Set flag of get count rows
*
Expand Down Expand Up @@ -2173,11 +2173,6 @@ public function afterSelect($trigger, $params = [], $modelClass = null, $isUse =
return $this->addTrigger('afterSelect', $trigger, $params, $modelClass, $isUse);
}

public function afterSelectCallback($callback, $params = [], $modelClass = null, $isUse = true)
{
return $this->addTrigger('afterSelect', $callback, $params, $modelClass, $isUse);
}

private function addTrigger($type, $trigger, $params, $modelClass, $isUse)
{
if (!$isUse) {
Expand All @@ -2195,6 +2190,11 @@ private function addTrigger($type, $trigger, $params, $modelClass, $isUse)
return $this;
}

public function afterSelectCallback($callback, $params = [], $modelClass = null, $isUse = true)
{
return $this->addTrigger('afterSelect', $callback, $params, $modelClass, $isUse);
}

public function beforeSelect($trigger, $params = [], $modelClass = null, $isUse = true)
{
return $this->addTrigger('beforeSelect', $trigger, $params, $modelClass, $isUse);
Expand Down Expand Up @@ -2452,7 +2452,10 @@ public function func($funcName, $argumentString, $modelTableData = [])

$this->select(
($fieldName ? strtoupper($fieldName) : '') . '(' .
(isset($fieldColumns[$argumentString]) ? $tableAlias . '.' . $fieldColumns[$argumentString] : $argumentString) .
(isset($fieldColumns[$argumentString])
? $tableAlias . '.' . $fieldColumns[$argumentString]
: ($argumentString === '' ? '""' : $argumentString)
) .
')',
$fieldAlias,
$modelTableData
Expand Down
3 changes: 3 additions & 0 deletions source/Ice/Helper/Type/Array.php
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,9 @@ public static function diffKey(array $old, array $new, $onlyChanges = false)
*/
public static function diff($old, $new, $onlyChanges = false)
{
$old = array_filter($old); // пока так, кому надо -
$new = array_filter($new); // реализует сравнение null-ов )

$diff = [
'added' => [],
'deleted' => []
Expand Down

0 comments on commit 2bc05f0

Please sign in to comment.