# File lib/ajaxim_drupaldb.rb, line 25
  def next_id(table)
    query("LOCK TABLE {sequences} WRITE")
    res = query("SELECT id FROM {sequences} WHERE name = '{#{table}}'")
    if res.num_rows > 0
      id = res.fetch_hash['id'].to_i + 1
    else
      id = 0
    end
    query("REPLACE INTO {sequences} VALUES ('{#{table}}', #{id})")
    query("UNLOCK TABLES")
    id
  end