Changeset 9039 for trunk/MagicSoft/Mars/msql
- Timestamp:
- 07/23/08 14:15:14 (16 years ago)
- Location:
- trunk/MagicSoft/Mars/msql
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/msql/MSQLMagic.cc
r9001 r9039 195 195 Bool_t MSQLMagic::ExistStr(const char *column, const char *table, const char *test, const char *where) 196 196 { 197 TString query(Form("SELECT %s FROM %s WHERE %s='%s' %s %s", column, table, column, test, where?"AND":"", where?where:"")); 197 TString query = test ? 198 Form("SELECT %s FROM %s WHERE %s='%s' %s %s", column, table, column, test, where?"AND":"", where?where:"") : 199 Form("SELECT %s FROM %s WHERE %s", column, table, where); 200 198 201 TSQLResult *res = Query(query); 199 202 if (!res) … … 211 214 delete res; 212 215 return rc; 216 } 217 218 // -------------------------------------------------------------------------- 219 // 220 // Check if at least one row with one field exists in table 221 // defined by where 222 // 223 Bool_t MSQLMagic::ExistRow(const char *table, const char *where) 224 { 225 return ExistStr("*", table, 0, where); 213 226 } 214 227 … … 306 319 // -------------------------------------------------------------------------- 307 320 // 321 // An abbreviation for checking whether a row with the condition where 322 // exists. If no such row exist Insert vars into table, otherwise update 323 // vars in table at row(s) defined by where. 324 // 325 Int_t MSQLMagic::InsertUpdate(const char *table, const char *vars, const char *where) 326 { 327 return ExistRow(table, where) ? 328 Update(table, vars, where) : 329 Insert(table, vars); 330 } 331 332 // -------------------------------------------------------------------------- 333 // 308 334 // An abbreviation for a Dalete-Query. 309 335 // -
trunk/MagicSoft/Mars/msql/MSQLMagic.h
r9001 r9039 45 45 Int_t QueryKeyOf(const char *col, const char *ext, const char *val); 46 46 Bool_t ExistStr(const char *column, const char *table, const char *test, const char *where=0); 47 Bool_t ExistRow(const char *table, const char *where); 47 48 48 49 Int_t Insert(const char *table, const char *vars, const char *where=0); … … 50 51 Int_t Delete(const char *table, const char *where); 51 52 Int_t InsertUpdate(const char *table, const char *col, const char *val, const char *vars); 53 Int_t InsertUpdate(const char *table, const char *vars, const char *where); 52 54 53 55 void Delete(const Option_t *o) { TObject::Delete(o); }
Note:
See TracChangeset
for help on using the changeset viewer.