[eluser]blasto333[/eluser]
Superclass Person model
Code:
/*
Inserts or updates a person
*/
function save(&$person_data,$person_id=false)
{
if (!$person_id or !$this->exists($person_id))
{
return $this->db->insert('people',$person_data);
}
$this->db->where('person_id', $person_id);
return $this->db->update('people',$person_data);
}
Subclass Customer model
Code:
/*
Inserts or updates a customer
*/
function save(&$person_data, &$customer_data,$customer_id=false)
{
$success=false;
//Run these queries as a transaction, we want to make sure we do all or nothing
$this->db->trans_start();
if(parent::save($person_data,$customer_id))
{
if (!$customer_id or !$this->exists($customer_id))
{
//THIS ALWAYS ENDS UP BEING 0 and NOT the insert_id of the row in the person table
$customer_data['person_id']=$this->db->insert_id();
$success = $this->db->insert('customers',$customer_data);
}
else
{
$this->db->where('person_id', $customer_id);
$success = $this->db->update('customers',$customer_data);
}
}
$this->db->trans_complete();
return $success;
}
How can I correctly get the subclass insert id without returning the value from the superclass? (This code worked fine pre php 5.3)