diff --git a/src/Phpmig/Adapter/Illuminate/Database.php b/src/Phpmig/Adapter/Illuminate/Database.php index 6e45ac1..bde22b5 100644 --- a/src/Phpmig/Adapter/Illuminate/Database.php +++ b/src/Phpmig/Adapter/Illuminate/Database.php @@ -5,8 +5,10 @@ */ namespace Phpmig\Adapter\Illuminate; +use PDO; use \Phpmig\Migration\Migration, \Phpmig\Adapter\AdapterInterface; +use RuntimeException; /** * @author Andrew Smith http://github.com/silentworks @@ -36,13 +38,27 @@ public function __construct($adapter, $tableName) */ public function fetchAll() { + $fetchMode = $this->adapter->connection() + ->getFetchMode(); + $all = $this->adapter->connection() ->table($this->tableName) ->orderBy('version') ->get(); - return array_map(function($v) { - return $v['version']; + return array_map(function($v) use($fetchMode) { + + switch ($fetchMode) { + + case PDO::FETCH_OBJ: + return $v->version; + + case PDO::FETCH_ASSOC: + return $v['version']; + + default: + throw new RuntimeException("The PDO::FETCH_* constant {$fetchMode} is not supported"); + } }, $all); }