Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Orm\Observer_UpdatedAt before_update? before_save?
  • Hi, I would like to ask one about Orm\Observer_UpdateAt on models.

    I got the following model code.
    protected static $_observers = array(
    'Orm\Observer_CreatedAt' => array(
    'events' => array('before_insert'),
    'mysql_timestamp' => true,
    'Orm\Observer_UpdatedAt' => array(
    'events' => array('before_update'),
    'mysql_timestamp' => true,

    With the above, when I update the model, the db column "updated_at" is not updated.
    If I try "before_save" instead, it works.

    What is the cause? 
    FYI, I post the updated part of controller (extends Controller_Rest).
    public function put_data()
        $props = Input::put();
        $model = Model_M_Company::find($props['id']);
            'name' => $props['name'],
            'tel' => $props['tel'],
            'address' => $props['address'],
            'remarks' => $props['remarks'],
            'company_status_id' => $props['company_status_id'],


    Thank you in advance.
  • HarroHarro
    Accepted Answer
    Which version of Fuel are you using?

    "before_update" support was added in 1.6.1.
  • Wow, I didn't know it. My version is 1.6.. Thanks!
    $ oil -v
    Fuel: 1.6 running in "development" mode
  • You can just copy the observer file from the 1.6.1. repo to make it work.

    1.7 will be released one of these days, you can also wait and upgrade to that.
  • Thank you for the advice. I did what you told:
    - Copying 1.6.1 version of fuel/packages/orm/classes/observer/updatedat.php

    That worked!! Thanks again.
  • You're welcome. Happy coding!

Howdy, Stranger!

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

In this Discussion