📜  如何在 ruby 中为 sql 数据库定义保存方法 - SQL 代码示例

📅  最后修改于: 2022-03-11 15:05:08.289000             🧑  作者: Mango

代码示例1
def save
    sql = <<-SQL
      INSERT INTO songs (name, album) 
      VALUES (?, ?)
    SQL
 
    DB[:conn].execute(sql, self.name, self.album)
 
    @id = DB[:conn].execute("SELECT last_insert_rowid() FROM songs")[0][0]
 
  end