Fix find functionality

This commit is contained in:
Dennis Eichhorn 2017-04-15 18:22:40 +02:00
parent 8c53047ee4
commit 50ab50c67e
2 changed files with 6 additions and 7 deletions

View File

@ -311,10 +311,9 @@ class DataMapperAbstract implements DataMapperInterface
foreach(static::$columns as $col) { foreach(static::$columns as $col) {
if(isset($col['autocomplete']) && $col['autocomplete']) { if(isset($col['autocomplete']) && $col['autocomplete']) {
$query->where($col['name'], 'LIKE', $search, 'OR'); $query->where(static::$table . '.' . $col['name'], 'LIKE', '%' . $search . '%', 'OR');
} }
} }
return static::getAllByQuery($query); return static::getAllByQuery($query);
} }

View File

@ -176,12 +176,12 @@ class Builder extends BuilderAbstract
protected $unionOrders = []; protected $unionOrders = [];
/** /**
* Comparison operators. * Comparison OPERATORS.
* *
* @var string[] * @var string[]
* @since 1.0.0 * @since 1.0.0
*/ */
/* public */ const operators = [ /* public */ const OPERATORS = [
'=', '=',
'<', '<',
'>', '>',
@ -459,14 +459,14 @@ class Builder extends BuilderAbstract
public function where($columns, $operator = null, $values = null, $boolean = 'and') : Builder public function where($columns, $operator = null, $values = null, $boolean = 'and') : Builder
{ {
// TODO: handle $value is null -> operator NULL // TODO: handle $value is null -> operator NULL
if (isset($operator) && !is_array($operator) && !in_array($operator, self::operators)) { if (isset($operator) && !is_array($operator) && !in_array(strtolower($operator), self::OPERATORS)) {
throw new \InvalidArgumentException('Unknown operator.'); throw new \InvalidArgumentException('Unknown operator.');
} }
if (is_array($columns)) { if (is_array($columns)) {
$i = 0; $i = 0;
foreach ($columns as $key => $column) { foreach ($columns as $key => $column) {
if (isset($operator[$i]) && !in_array($operator[$i], self::operators)) { if (isset($operator[$i]) && !in_array(strtolower($operator[$i]), self::OPERATORS)) {
throw new \InvalidArgumentException('Unknown operator.'); throw new \InvalidArgumentException('Unknown operator.');
} }
@ -480,7 +480,7 @@ class Builder extends BuilderAbstract
$i++; $i++;
} }
} elseif (is_string($columns)) { } elseif (is_string($columns)) {
if (isset($operator) && !in_array($operator, self::operators)) { if (isset($operator) && !in_array(strtolower($operator), self::OPERATORS)) {
throw new \InvalidArgumentException('Unknown operator.'); throw new \InvalidArgumentException('Unknown operator.');
} }