Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Duplicate and save object
  • Hey,
    is there a way to Find and save object as new?
    Currently I'm using Find then forge new object and setting all of its properties from the Original object, then save the new object, is there a shorter way for this? 
    Any clue would be appreciated
  • philipptempelphilipptempel
    Accepted Answer
    You can clone (duplicate) any object in PHP using $new = clone $old which will result in an new object $new with the same properties as $old except that it doesn't have any primary keys set thus must be saved to the database to be persistent.
  • That was a great info, Thanks a lot. 

Howdy, Stranger!

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

In this Discussion