Skip to content
Permalink
Browse files

Add types into $options array.

  • Loading branch information...
dereuromark committed Mar 12, 2018
1 parent 9c36a48 commit a71aa15df17eaaffe7a6233ab84875cd6065935f
Showing with 24 additions and 10 deletions.
  1. +24 −10 src/Database/Query.php
@@ -894,43 +894,57 @@ public function where($conditions = null, $types = [], $overwrite = false)
* query.
*
* This method does allow empty inputs in contrast to where() if you set
* $allowEmpty to true.
* 'allowEmpty' to true.
* Be careful about using it without proper sanity checks.
*
* Options:
* - `types` - Associative array of type names used to bind values to query
* - `allowEmpty` - Allow empty array.
*
* @param string $field Field
* @param array $values Array of values
* @param bool $allowEmpty Allow empty array
* @param array $options Options
* @return $this
*/
public function whereIn($field, array $values, $allowEmpty = false)
public function whereIn($field, array $values, array $options = [])
{
if ($allowEmpty && !$values) {
$options += [
'types' => [],
'allowEmpty' => false,
];
if ($options['allowEmpty'] && !$values) {
return $this->where('1=0');
}
return $this->where([$field . ' IN' => $values]);
return $this->where([$field . ' IN' => $values], $options['types']);
}
/**
* Adds a NOT IN condition or set of conditions to be used in the WHERE clause for this
* query.
*
* This method does allow empty inputs in contrast to where() if you set
* $allowEmpty to true.
* 'allowEmpty' to true.
* Be careful about using it without proper sanity checks.
*
* @param string $field Field
* @param array $values Array of values
* @param bool $allowEmpty Allow empty array
* @param array $options Options
* @return $this
*/
public function whereNotIn($field, array $values, $allowEmpty = false)
public function whereNotIn($field, array $values, array $options = [])
{
if ($allowEmpty && !$values) {
$options += [
'types' => [],
'allowEmpty' => false,
];
if ($options['allowEmpty'] && !$values) {
return $this->where('1=1');
}
return $this->where([$field . ' NOT IN' => $values]);
return $this->where([$field . ' NOT IN' => $values], $options['types']);
}
/**

0 comments on commit a71aa15

Please sign in to comment.
You can’t perform that action at this time.