Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Type checking with ORM?
  • Sadly, it appears that Orm doesn't respect the database set type. If I use an integer for a column type, it gets cast to a string. Setting the data_type parameter on the \Orm\Model's properties doesn't fix the issue. For now, I'll cast the variable to the proper type, but for best practice it really should retain it's type. The more strictly you code, the less chance for errors later on, so I like to do a lot of type checking.

    Am I missing something on how to retain the type? If it's not possible to retain the type in version 1.X, will version 2 or FuelPHP retain the type?
  • HarroHarro
    Accepted Answer
    Orm doesn't do that, MySQL does that. The PHP MySQL library returns ALL results as string.

    The data_type property works together with the "Observer_Typing", so you need to add that to your model to make it work. Check http://docs.fuelphp.compackages/orm/observers/included.html#os_typing
  • Nice. My mistake. I didn't realize you had that already in the framework. Thanks for the help!

Howdy, Stranger!

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

In this Discussion