loaded) { throw new Exception("@todo GROUP_ALREADY_EXISTS $name"); } $group->name = $name; $group->save(); // Create the view column for this group in the items table. Database::instance()->query("ALTER TABLE `items` ADD `view_{$group->id}` BOOLEAN DEFAULT 0"); return $group; } /** * Delete a group * * @param string $name the group name */ static function delete($name) { $group = ORM::factory("group")->where("name", $name)->find(); if ($group->loaded) { // Drop the view column for this group in the items table. Database::instance()->query("ALTER TABLE `items` DROP `view_{$group->id}`"); $group->delete(); } } }