Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Convert ORM Object to Simple Object
  • Just wondering if there would be a feature to convert the Object from the ORM with its private and protected methods to a simple object which is the final objects/arrays. I honestly don't know if it has any performance impact at all, just trying to see if it would have an advantage when caching the simple object as serialized or JSON since it will be shorter.
  • $model->to_array();
    

    Should be enough, I don't see any use in converting it to a stdClass object.
  • Jelmer Schreuder wrote on Sunday 29th of May 2011:
    $model->to_array();
    

    Should be enough, I don't see any use in converting it to a stdClass object.
    I tried that but when its unserialize the related objects are arrays not objects so in views its $articles->posts
    Also to_array() doesn't seem to work when its get() method , since it returns an array of objects, get_one() however works.
    ErrorException [ Error ]: Call to a member function to_array() on a non-object
    

Howdy, Stranger!

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

In this Discussion