Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Oil generate - Questions and Confirmation of use
  • ok,
    I think i am getting this all now, but just want to make sure I understand it.

    I can use Oil to generate the basic structure of a table/model, BUT it will not do any sort of relationships, correct?
    So if I had a car and color table, I would need to do something like:
    oil g color name:string
    oil g car name:string color_id:int

    and then manually update the models to relate the field 'color_id' to the color.id field, right?

    Also, then the same thing for the many-to-many ... I have to create the table manually, but then just make the changes in each of the models to tell it which table/col to reference? (ex: http://fuelphp.com/docs/packages/orm/relations/many_many.html ), right?

    thanks.

  • Correct.

    Oil can generate both Model_Crud and ORM models, but it is not aware of relationships. You have to add the $_belongs_to, $_has_one, $_has_many and $_many_many definitions yourself.
  • Thanks.

    And I thought i remember reading it somewhere, but is it possible to use oil to update a model and crud as well?

    Like if i created the 'Color' model and did a migrate, can I go back and add 'from_manufacturer' to and and have the model, crud and db get updated?

    Is there more detailed info on what oil generate takes in for the model properties (not null / not required, etc..) or are these all things I need to change in the model validation?

    Thanks.

  • No, oil always generates and overwrites, so you will loose any manual updates.

    If you want incremental generation, perhaps it's a better option to start at the table end, and use the fromdb task to generate the model based on the table definition (works for MySQL only, and only using the mysql or myqli drivers!).

    With regards to properties, are you using ORM or Model_Crud?

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion