Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
ErrorException [ Error ]: Call to undefined method Orm\Query::save() when trying to update a record
  • The following error gets thrown when the $tracking->save(); method is called in the below code... ErrorException [ Error ]: Call to undefined method Orm\Query::save() This is an extract from my Model_Signup() class:
     $referrer = self::find()->where('ref', $ref);
      
     if ($referrer->count() > 0)
     { 
      $referrer = $referrer->get_one();
      Cookie::set('signup_referral_tracking', json_encode(array('referrer' => $referrer->ref)));
       
      // if the click through var is true increase the referrers tracker
      if ($click_through == true)
      {
       $tracking = Model_Tracking::find()->where('email_id', $referrer->id);
       $tracking->click_count++;
       $tracking->save();
      }
      
      return $referrer;
     }
    

    I'm not sure if this is a best practice approach and am open for suggestions on how to improve as well as a reason for why this isn't working. I've tried $tracking->get_one() before the save which also doesn't work.
  • Why not just do $referrer = self::find_by_ref($ref) instead of trying to do the query manually? You need to use that approach or ->execute() the query.
  • Thanks for the quick reply Phil.
    Seems to work perfect using your recommended approach. Just as a rule of thumb. Is Model_Name::find_by_column_name($param) valid for all Orm models?

Howdy, Stranger!

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

In this Discussion