Skip to content

Instantly share code, notes, and snippets.

@rlemon
Created December 6, 2011 17:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rlemon/1439130 to your computer and use it in GitHub Desktop.
Save rlemon/1439130 to your computer and use it in GitHub Desktop.
updateItem method
public function updateItem($id, $map, $groups) {
$this->updateData('inventory', $id, $map); // I update all the columns in the item table
$dbo = $this->db->exec('DELETE FROM group_item_mapping WHERE item_id = ' . $id); // here is where I remove the group enrollments.
for($i = 0, $l = count($groups); $i < $l; $i++) {
// here I re-add the enrollments for the selected checkbox options.
$this->addData('INSERT INTO group_item_mapping (item_id, group_id) VALUES (:item_id, :group_id)', array( ':item_id' => $id, ':group_id' => $groups[$i] ));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment