Ignore:
Timestamp:
2008-05-22T14:06:54+12:00 (16 years ago)
Author:
mdewsnip
Message:

(Adding new DB support) Changing the setinfo() function to use either INSERT or UPDATE, depending on whether the key already exists.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • gsdl/trunk/lib/sqliteclass.cpp

    r15635 r15636  
    182182  }
    183183
    184   outconvertclass text_t2ascii;
    185   (*logout) << text_t2ascii << "Inserting for " << key << ":\n" << data << "\n";
    186 
    187   text_t sql_cmd = "INSERT INTO data (key, value) VALUES ('" + key + "', '" + data + "')";
    188   return sqlexec(sql_cmd);
     184  // We need to do either an INSERT or UPDATE depending on whether the key already exists
     185  if (!exists(key))
     186  {
     187    text_t sql_cmd = "INSERT INTO data (key, value) VALUES ('" + key + "', '" + data + "')";
     188    return sqlexec(sql_cmd);
     189  }
     190  else
     191  {
     192    text_t sql_cmd = "UPDATE data SET value='" + data + "' WHERE key='" + key + "'";
     193    return sqlexec(sql_cmd);
     194  }
    189195}
    190196
Note: See TracChangeset for help on using the changeset viewer.