// truncate persons, jobs and persons_jobs
DBUtil::truncate_table('persons');
DBUtil::truncate_table('jobs');
DBUtil::truncate_table('jobs_people');
// create test data
$query = DB::insert('persons', array('name'))->values(array('Person 1'))->execute();
$query = DB::insert('jobs', array('name'))->values(array('Job 1'))->execute();
$query = DB::insert('jobs', array('name'))->values(array('job 2'))->execute();
$query = DB::insert('jobs', array('name'))->values(array('job 3'))->execute();
// relate person 1 to Job 2
$person = Model_Person::find(1);
$person->job[2] = Model_Job::find(2);
$person->save();
INSERT INTO `jobs_people` (`person_id`, `job_id`) VALUES (1, '2')
It looks like you're new here. If you want to get involved, click one of these buttons!