Changeset 15635

Show
Ignore:
Timestamp:
22.05.2008 13:58:47 (11 years ago)
Author:
mdewsnip
Message:

(Adding new DB support) Tidied up checking for sqlitefile == NULL so this is only done in the core SQL functions.

Files:
1 modified

Legend:

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

    r15634 r15635  
    5454 
    5555  char *filename_cstr = filename.getcstr(); 
    56   sqlitefile = NULL; 
    5756  sqlite3_open(filename_cstr, &sqlitefile); 
    5857  delete[] filename_cstr; 
     
    6059  if (sqlitefile == NULL) 
    6160  { 
    62     outconvertclass text_t2ascii; 
    63     (*logout) << text_t2ascii << "database open failed on: " << filename << "\n"; 
     61    (*logout) << "ERROR: sqliteclass::opendatabase() failed on: " << filename << "\n"; 
    6462    return false; 
    6563  } 
     
    8987  text_t sql_cmd = "SELECT value FROM data WHERE key='" + key + "'"; 
    9088  vector<text_tmap> sql_results; 
    91   if (sqlitefile == NULL || !sqlgetarray(sql_cmd, sql_results) || sql_results.size() == 0) 
     89  if (!sqlgetarray(sql_cmd, sql_results) || sql_results.size() == 0) 
    9290  { 
    9391    return false; 
     
    113111  text_t sql_cmd = "SELECT value FROM data WHERE key='" + key + "'"; 
    114112  vector<text_tmap> sql_results; 
    115   if (sqlitefile == NULL || !sqlgetarray(sql_cmd, sql_results) || sql_results.size() == 0) 
     113  if (!sqlgetarray(sql_cmd, sql_results) || sql_results.size() == 0) 
    116114  { 
    117115    return false; 
     
    125123bool sqliteclass::setinfo(const text_t &key, const infodbclass &info) 
    126124{ 
    127   if (sqlitefile == NULL) return false; 
    128  
    129125  text_t subkey; 
    130126  text_t data; 
     
    208204  text_t sql_cmd = "SELECT key FROM data"; 
    209205  vector<text_tmap> sql_results; 
    210   if (sqlitefile == NULL || !sqlgetarray(sql_cmd, sql_results) || sql_results.size() == 0) 
     206  if (!sqlgetarray(sql_cmd, sql_results) || sql_results.size() == 0) 
    211207  { 
    212208    return keys; 
     
    281277bool sqliteclass::sqlexec(const text_t &sql_cmd) 
    282278{ 
     279  if (sqlitefile == NULL) return false; 
     280 
    283281  char *sql_cmd_cstr = sql_cmd.getcstr(); 
    284282 
     
    332330bool sqliteclass::sqlgetarray(const text_t &sql_cmd, vector<text_tmap> &sql_results) 
    333331{ 
     332  if (sqlitefile == NULL) return false; 
     333 
    334334  char *sql_cmd_cstr = sql_cmd.getcstr(); 
    335335  sql_results.erase(sql_results.begin(), sql_results.end());