# File model/model.rb, line 561
    def create(type,values)
        check_dbh

        case type
        when 'cookbook'
            @dbh.do('insert into cookbook (cookbook_id,name) values (NULL,?)',
                values['name'])
            @dbh.commit

            id = @dbh.select_one('select max(cookbook_id) from cookbook')[0].to_i
            @hash['cookbook'] = Hash.new if @hash['cookbook'].nil?
            @hash['cookbook'][id] = Cookbook.new(@dbh, id)
            @cookbooks << @hash['cookbook'][id]
            return @hash['cookbook'][id]

        when 'category'
            @dbh.do('insert into category (cookbook_id,name) values (?,?)',
                values['cookbook_id'], values['name'])
            @dbh.commit

            id = @dbh.select_one('select max(category_id) from category')[0].to_i
            @hash['category'] = Hash.new if @hash['category'].nil?
            c = @hash['category'][id] = Category.new(@dbh, id)
            @hash['cookbook'][values['cookbook_id']].categories << c
            return c

        when 'recipe'
            @dbh.do('insert into recipe (recipe_id,name) values (NULL,?)',
                values['name'])
            @dbh.commit

            id = @dbh.select_one('select max(recipe_id) from recipe')[0].to_i
            @hash['recipe'] = Hash.new if @hash['recipe'].nil?
            return @hash['recipe'][id] = Recipe.new(@dbh, id)

        when 'ingredient'
            row = @dbh.select_one('select max(position) from ingredient where recipe_id=?',values['recipe_id'])
            position = (row ? row[0].to_i + 1 : 1)

            @dbh.do('insert into ingredient (recipe_id,measure_id,quantity,food_id,modifier,position) values (?,?,?,?,?,?)',
                values['recipe_id'],
                values['measure_id'],
                values['quantity'],
                values['food_id'],
                values['modifier'],
                position)
            @dbh.commit

            id = @dbh.select_one('select max(ingredient_id) from ingredient')[0].to_i
            @hash['ingredient'] = Hash.new if @hash['ingredient'].nil?
            i = @hash['ingredient'][id] = Ingredient.new(@dbh, id)
            @hash['recipe'][values['recipe_id']].ingredients << i
            return i

        when 'food'
            @dbh.do('insert into food (name) values (?)', values['name'])
            @dbh.commit

            id = @dbh.select_one('select max(food_id) from food')[0].to_i
            @hash['food'] = Hash.new if @hash['food'].nil?
            f = @hash['food'][id] = Food.new(@dbh, id)
            @foods << f
            return f

        when 'measure'
            @dbh.do('insert into measure (measure_id) values (NULL)')
            @dbh.commit

            id = @dbh.select_one('select max(measure_id) from measure')[0].to_i
            @hash['measure'] = Hash.new if @hash['measure'].nil?
            m = @hash['measure'][id] = Measure.new(@dbh, id)
            @measures << m
            return m

        else raise "Invalid Record Type"
        end
    end