Fixed bug in bindings that was causing null to be saved as 0 in MySQL.
This commit is contained in:
parent
d95ead812a
commit
514c128957
|
@ -52,7 +52,21 @@ public static function query($sql, $bindings = array(), $connection = null)
|
||||||
{
|
{
|
||||||
$query = static::connection($connection)->prepare($sql);
|
$query = static::connection($connection)->prepare($sql);
|
||||||
|
|
||||||
$result = $query->execute($bindings);
|
$bindings = array_values($bindings);
|
||||||
|
|
||||||
|
foreach ($bindings as $key => &$binding)
|
||||||
|
{
|
||||||
|
if (is_null($binding))
|
||||||
|
{
|
||||||
|
$query->bindValue($key + 1, null, \PDO::PARAM_INT);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$query->bindParam($key + 1, $binding);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = $query->execute();
|
||||||
|
|
||||||
if (strpos(strtoupper($sql), 'SELECT') === 0)
|
if (strpos(strtoupper($sql), 'SELECT') === 0)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue