Skip to content

Commit

Permalink
Merge pull request #36 from thomseddon/fix/return-native-array
Browse files Browse the repository at this point in the history
Convert all ArrayObjects to native arrays [Trying to solve broken down migrations]
  • Loading branch information
duxet authored Nov 16, 2016
2 parents 2548d00 + c645407 commit a6e70b7
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,21 @@ public function run($query = null)
$time = $this->connection->getElapsedTime($start);
$this->connection->logQuery($query, [], $time);

return $result;
return $this->nativeArray($result);
}

private function nativeArray($val)
{
if (is_array($val)) {
foreach ($val as $k => $v) {
$val[$k] = $this->nativeArray($v);
}

return $val;
} elseif (is_object($val) && $val instanceof \ArrayObject) {
return $val->getArrayCopy();
} else {
return $val;
}
}
}

0 comments on commit a6e70b7

Please sign in to comment.