Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
ORM doesn't work on Triggered Query
  • I'm trying to build Vote system. I'm writing every single points to a table..
    AFTER INSERT i'm trying trig a trigger in MySQL which re-calculate points and updates on another table. When i try to insert with ORM. After ->save method i can't fetch re-calculated point from another table.. Do i missing something? Or is this a bug or something?
    Thank you.
  • Can you be more specific? What is "can't"? What happens? Any errors?
  • There is no error. Problem is; I need to get re-calculated points. But it doesn't give the updated points. It gives me the previous points. When i check the database the points is changed but the data that ORM send me is previous datas..

    $experience_point = new \Model_ExperiencePoint(array(
       'experience_id' => $experience_id,
       'user_id' => $this->user_id,
       'point' => $point
     ));
    $experience_point->save();
    $experience = \Model_Experience::find_by_id($experience_id);
    

    *experience's point is changing when points came(to experience_points table).
    (it's re-calculating and updating the points field with before_insert trigger in another table(experience). But after save it doesn't fetch re-calculated points. It gives the old(previous) points. PS: I checked many time. Database works fine.
  • Ah, you query the same data twice in a single request? Our ORM is a Datamapper, which means it has a unified datastore which is used internally. When you request the same object twice, it is returned from the datastore, no query is executed. With this kind of architecture you shouldn't manipulate the data without the ORM's knowledge. You could work around this by overloading the cached_object() method in your model, and have it return false for this specific model.

Howdy, Stranger!

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

In this Discussion