Welcome Guest, Not a member yet? Register   Sign In
Can't update a controller variable in model
#2

[eluser]boltsabre[/eluser]
You're close, but you must return your new vendor id from the model like this.

Code:
// controller
$vend_id = $this->m_client->save_vendor();
if($vend_id !== true){
   // not returning true, so must be a new vendor id from model, update our controller vendor_id
   $this->vendor_id = $vend_id;
}

Code:
//model
...
if($this->vendor_id)
   {
     $this->db->where('vendor_id',$this->vendor_id);
     $this->db->update('vendor',$vendor_data);
     return true
   }else{
     $this->db->insert('vendor',$vendor_data);
     return $this->db->insert_id();
   }

You cant just access variables set in a model direct from your controller, you must pass them back (otherwise you'd run the risk of "over riding" your controller variables from your model if you mistakenly called them both the same thing).


Messages In This Thread
Can't update a controller variable in model - by El Forum - 05-10-2012, 02:14 AM
Can't update a controller variable in model - by El Forum - 05-10-2012, 05:25 AM
Can't update a controller variable in model - by El Forum - 05-10-2012, 08:24 AM
Can't update a controller variable in model - by El Forum - 05-10-2012, 10:43 AM



Theme © iAndrew 2016 - Forum software by © MyBB