File tree Expand file tree Collapse file tree 1 file changed +18
-2
lines changed
src/Phpmig/Adapter/Illuminate Expand file tree Collapse file tree 1 file changed +18
-2
lines changed Original file line number Diff line number Diff line change 55 */
66namespace Phpmig \Adapter \Illuminate ;
77
8+ use PDO ;
89use \Phpmig \Migration \Migration ,
910 \Phpmig \Adapter \AdapterInterface ;
11+ use RuntimeException ;
1012
1113/**
1214 * @author Andrew Smith http://github.com/silentworks
@@ -36,13 +38,27 @@ public function __construct($adapter, $tableName)
3638 */
3739 public function fetchAll ()
3840 {
41+ $ fetchMode = $ this ->adapter ->connection ()
42+ ->getFetchMode ();
43+
3944 $ all = $ this ->adapter ->connection ()
4045 ->table ($ this ->tableName )
4146 ->orderBy ('version ' )
4247 ->get ();
4348
44- return array_map (function ($ v ) {
45- return $ v ['version ' ];
49+ return array_map (function ($ v ) use ($ fetchMode ) {
50+
51+ switch ($ fetchMode ) {
52+
53+ case PDO ::FETCH_OBJ :
54+ return $ v ->version ;
55+
56+ case PDO ::FETCH_ASSOC :
57+ return $ v ['version ' ];
58+
59+ default :
60+ throw new RuntimeException ("The PDO::FETCH_* constant {$ fetchMode } is not supported " );
61+ }
4662 }, $ all );
4763 }
4864
You can’t perform that action at this time.
0 commit comments