iberflow / laravel-model-generator

Laravel 5 model generator for an existing schema
264 stars 76 forks source link

Handle fetch type in making models #21

Closed calina-c closed 8 years ago

calina-c commented 8 years ago

Currently in MakeModelsCommand line 109 we have $this->generateTable($table->name);

However the -> operator only works if the fetch style in database.php is 'FETCH_CLASS'. Some devs prefer'FETCH_ASSOC'to make the SQL results arrays of arrays, not arrays of objects. The problem is that it also fails without any clue to the cause.

The code should take this into consideration.

(I can handle it via a MR today or tomorrow, if you want.)

iberflow commented 8 years ago

Hi there, Thanks for the PR, however I think a cleaner solution would be to set the fetch mode prior to invoking the queries, then there's no change to the code.

Fixed in 1.1.4 with 343ad81