Skip to content

Commit

Permalink
Fix PDO connection on HHVM with the default "class without name" case (
Browse files Browse the repository at this point in the history
…#14429)

HHVM doesn't support using an empty array to omit the 3rd parameter "constructor argument".
  • Loading branch information
vlakoff authored and taylorotwell committed Jul 22, 2016
1 parent ceccdf7 commit f6a4db4
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/Illuminate/Database/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -336,13 +336,15 @@ public function select($query, $bindings = [], $useReadPdo = true)

$fetchMode = $me->getFetchMode();
$fetchArgument = $me->getFetchArgument();
$fetchConstructorArgument = $me->getFetchConstructorArgument();

if ($fetchMode === PDO::FETCH_CLASS && ! isset($fetchArgument)) {
$fetchArgument = 'StdClass';
$fetchConstructorArgument = null;
}

return isset($fetchArgument)
? $statement->fetchAll($fetchMode, $fetchArgument, $me->getFetchConstructorArgument())
? $statement->fetchAll($fetchMode, $fetchArgument, $fetchConstructorArgument)
: $statement->fetchAll($fetchMode);
});
}
Expand All @@ -366,13 +368,15 @@ public function cursor($query, $bindings = [], $useReadPdo = true)

$fetchMode = $me->getFetchMode();
$fetchArgument = $me->getFetchArgument();
$fetchConstructorArgument = $me->getFetchConstructorArgument();

if ($fetchMode === PDO::FETCH_CLASS && ! isset($fetchArgument)) {
$fetchArgument = 'StdClass';
$fetchConstructorArgument = null;
}

if (isset($fetchArgument)) {
$statement->setFetchMode($fetchMode, $fetchArgument, $me->getFetchConstructorArgument());
$statement->setFetchMode($fetchMode, $fetchArgument, $fetchConstructorArgument);
} else {
$statement->setFetchMode($fetchMode);
}
Expand Down

0 comments on commit f6a4db4

Please sign in to comment.