mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-01-21 13:58:42 +00:00
fix where query usage
This commit is contained in:
parent
b1e3eac74c
commit
bd927133d7
|
|
@ -20,6 +20,7 @@ use phpOMS\DataStorage\Database\Query\Builder;
|
|||
use phpOMS\DataStorage\Database\Query\QueryType;
|
||||
use phpOMS\DataStorage\DataMapperInterface;
|
||||
use phpOMS\Utils\ArrayUtils;
|
||||
use phpOMS\DataStorage\Database\Query\Where;
|
||||
|
||||
/**
|
||||
* Datamapper for databases.
|
||||
|
|
@ -394,18 +395,24 @@ class DataMapperAbstract implements DataMapperInterface
|
|||
{
|
||||
$query ??= static::getQuery(null, [], RelationType::ALL, $searchDepth);
|
||||
|
||||
$where1 = new Where(self::$db);
|
||||
$where2 = new Where(self::$db);
|
||||
|
||||
foreach (self::$conditionals as $condKey => $condValue) {
|
||||
if (($column = self::getColumnByMember($condKey)) !== null) {
|
||||
$query->andWhere(static::$table . '_' . $searchDepth . '.' . $column, '=', $condValue);
|
||||
$where1->andWhere(static::$table . '_' . $searchDepth . '.' . $column, '=', $condValue);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (static::$columns as $col) {
|
||||
if (isset($col['autocomplete']) && $col['autocomplete']) {
|
||||
$query->where(static::$table . '_' . $searchDepth . '.' . $col['name'], 'LIKE', '%' . $search . '%', 'OR');
|
||||
$where2->where(static::$table . '_' . $searchDepth . '.' . $col['name'], 'LIKE', '%' . $search . '%', 'OR');
|
||||
}
|
||||
}
|
||||
|
||||
$query->andWhere($where1);
|
||||
$query->andWhere($where2);
|
||||
|
||||
if ($searchDepth > 2) {
|
||||
foreach (static::$ownsOne as $one) {
|
||||
$one['mapper']::findQuery($search, $searchDepth - 1, $query);
|
||||
|
|
|
|||
|
|
@ -553,7 +553,7 @@ class Builder extends BuilderAbstract
|
|||
}
|
||||
|
||||
$i = 0;
|
||||
foreach ($columns as $key => $column) {
|
||||
foreach ($columns as $column) {
|
||||
if (isset($operator[$i]) && !\in_array(\strtolower($operator[$i]), self::OPERATORS)) {
|
||||
throw new \InvalidArgumentException('Unknown operator.');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -216,8 +216,8 @@ class Grammar extends GrammarAbstract
|
|||
{
|
||||
$expression = '';
|
||||
|
||||
foreach ($wheres as $key => $where) {
|
||||
foreach ($where as $key2 => $element) {
|
||||
foreach ($wheres as $where) {
|
||||
foreach ($where as $element) {
|
||||
$expression .= $this->compileWhereElement($element, $query, $first);
|
||||
$first = false;
|
||||
}
|
||||
|
|
@ -440,7 +440,7 @@ class Grammar extends GrammarAbstract
|
|||
{
|
||||
$expression = '';
|
||||
|
||||
foreach ($ons as $key => $on) {
|
||||
foreach ($ons as $on) {
|
||||
$expression .= $this->compileOnElement($on, $query, $first);
|
||||
$first = false;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user