-
Notifications
You must be signed in to change notification settings - Fork 439
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#6632 Patch illuminate/database binding issue (stable-3_2_0)
- Loading branch information
Showing
3 changed files
with
142 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
diff --git a/src/Illuminate/Database/Query/Builder.php b/src/Illuminate/Database/Query/Builder.php | ||
index 0d4c7c3ae16..83416d83be0 100755 | ||
--- a/src/Illuminate/Database/Query/Builder.php | ||
+++ b/src/Illuminate/Database/Query/Builder.php | ||
@@ -698,7 +698,7 @@ public function where($column, $operator = null, $value = null, $boolean = 'and' | ||
); | ||
|
||
if (! $value instanceof Expression) { | ||
- $this->addBinding($value, 'where'); | ||
+ $this->addBinding(is_array($value) ? head($value) : $value, 'where'); | ||
} | ||
|
||
return $this; | ||
@@ -1043,7 +1043,7 @@ public function whereBetween($column, array $values, $boolean = 'and', $not = fa | ||
|
||
$this->wheres[] = compact('type', 'column', 'values', 'boolean', 'not'); | ||
|
||
- $this->addBinding($this->cleanBindings($values), 'where'); | ||
+ $this->addBinding(array_slice($this->cleanBindings($values), 0, 2), 'where'); | ||
|
||
return $this; | ||
} | ||
@@ -1111,6 +1111,8 @@ public function whereDate($column, $operator, $value = null, $boolean = 'and') | ||
$value, $operator, func_num_args() === 2 | ||
); | ||
|
||
+ $value = is_array($value) ? head($value) : $value; | ||
+ | ||
if ($value instanceof DateTimeInterface) { | ||
$value = $value->format('Y-m-d'); | ||
} | ||
@@ -1150,6 +1152,8 @@ public function whereTime($column, $operator, $value = null, $boolean = 'and') | ||
$value, $operator, func_num_args() === 2 | ||
); | ||
|
||
+ $value = is_array($value) ? head($value) : $value; | ||
+ | ||
if ($value instanceof DateTimeInterface) { | ||
$value = $value->format('H:i:s'); | ||
} | ||
@@ -1189,6 +1193,8 @@ public function whereDay($column, $operator, $value = null, $boolean = 'and') | ||
$value, $operator, func_num_args() === 2 | ||
); | ||
|
||
+ $value = is_array($value) ? head($value) : $value; | ||
+ | ||
if ($value instanceof DateTimeInterface) { | ||
$value = $value->format('d'); | ||
} | ||
@@ -1232,6 +1238,8 @@ public function whereMonth($column, $operator, $value = null, $boolean = 'and') | ||
$value, $operator, func_num_args() === 2 | ||
); | ||
|
||
+ $value = is_array($value) ? head($value) : $value; | ||
+ | ||
if ($value instanceof DateTimeInterface) { | ||
$value = $value->format('m'); | ||
} | ||
@@ -1275,6 +1283,8 @@ public function whereYear($column, $operator, $value = null, $boolean = 'and') | ||
$value, $operator, func_num_args() === 2 | ||
); | ||
|
||
+ $value = is_array($value) ? head($value) : $value; | ||
+ | ||
if ($value instanceof DateTimeInterface) { | ||
$value = $value->format('Y'); | ||
} | ||
@@ -1583,7 +1593,7 @@ public function whereJsonLength($column, $operator, $value = null, $boolean = 'a | ||
$this->wheres[] = compact('type', 'column', 'operator', 'value', 'boolean'); | ||
|
||
if (! $value instanceof Expression) { | ||
- $this->addBinding($value); | ||
+ $this->addBinding((int) $value); | ||
} | ||
|
||
return $this; | ||
@@ -1732,7 +1742,7 @@ public function having($column, $operator = null, $value = null, $boolean = 'and | ||
$this->havings[] = compact('type', 'column', 'operator', 'value', 'boolean'); | ||
|
||
if (! $value instanceof Expression) { | ||
- $this->addBinding($value, 'having'); | ||
+ $this->addBinding(is_array($value) ? head($value) : $value, 'having'); | ||
} | ||
|
||
return $this; |