I have three table company,group and company_group.
I am getting values from post while saving a company.
In my company form i have multiple select box which has a list of group.
My company is getting saved correct-ally but now i want to add record in company_group table with last inserted id of company and selected group.
I have set up has_many in both models company and group but cannot save multiple records in company_group table so help me with this.
Company model
class Company extends DataMapper {
var $has_one=array("group");
function __construct() {
parent::DataMapper();
}
}
group model
class Group extends DataMapper {
var $has_many=array("company");
function __construct() {
parent::DataMapper();
}
}
company controller
class Company_c extends CI_Controller {
public function index() {
$company = new company();
$group=new group();
$company->id=1;
$group->id=2;
$group->id=4;
$company->save($group);
}
}
Please help me with this