[eluser]mikertjones[/eluser]
Hi
This is frustrating
Controller Clients declares var:
Controller adds or updates client records using model m_client.
If a vendor_id exists it updates the vendor record, if not it creates a new one.
So, in the Controller Clients.php
Code:
$this->m_client->save_vendor();
and in the model m_client.php
Code:
function save_vendor()
{
$num_items = empty($_POST['num_items'])?0:$this->input->post('num_items');
$vendor_data = array(
'client_id'=>$this->client_id,
'auction_id'=>$this->auction_id,
'vendor_ref'=>$this->input->post('auction_vendor_ref'),
'reference_address'=>$this->input->post('reference_address'),
'num_items'=>$num_items);
if($this->vendor_id)
{
$this->db->where('vendor_id',$this->vendor_id);
$this->db->update('vendor',$vendor_data);
}else{
$this->db->insert('vendor',$vendor_data);
$this->vendor_id = $this->db->insert_id();
}
} // END fn save_vendor
Testing in the context of the model, if a new vendor record is added, $this->vendor_id has a value.
Testing back in Client controller $this->vendor_id has no value even after the call to m_client->save_vendor.
I am expecting that if a new vendor record is inserted that the line
Code:
$this->vendor_id = $this->db->insert_id();
would update the $this->vendor_id value accessible back in the Controller - I need it to call another model function.
Any thoughts?
Thanks
Mike