| 219 | } |
| 220 | |
| 221 | S32 SQLiteObject::ExecuteSQL(const char* sql) |
| 222 | { |
| 223 | S32 iResult; |
| 224 | sqlite_resultset* pResultSet; |
| 225 | |
| 226 | // create a new resultset |
| 227 | pResultSet = new sqlite_resultset; |
| 228 | |
| 229 | if (pResultSet) |
| 230 | { |
| 231 | pResultSet->bValid = false; |
| 232 | pResultSet->iCurrentColumn = 0; |
| 233 | pResultSet->iCurrentRow = 0; |
| 234 | pResultSet->iNumCols = 0; |
| 235 | pResultSet->iNumRows = 0; |
| 236 | pResultSet->iResultSet = m_iNextResultSet; |
| 237 | pResultSet->vRows.clear(); |
| 238 | m_iLastResultSet = m_iNextResultSet; |
| 239 | m_iNextResultSet++; |
| 240 | } |
| 241 | else |
| 242 | return 0; |
| 243 | |
| 244 | iResult = sqlite3_exec(m_pDatabase, sql, Callback, (void*)pResultSet, &m_szErrorString); |
| 245 | if (iResult == 0) |
| 246 | { |
| 247 | //SQLITE_OK |
| 248 | SaveResultSet(pResultSet); |
| 249 | Con::executef(this, "1", "onQueryFinished()"); |
| 250 | return pResultSet->iResultSet; |
| 251 | } |
| 252 | else |
| 253 | { |
| 254 | // error occured |
| 255 | Con::executef(this, "2", "onQueryFailed", m_szErrorString); |
| 256 | Con::errorf("SQLite failed to execute query, error %s", m_szErrorString); |
| 257 | delete pResultSet; |
| 258 | return 0; |
| 259 | } |
| 260 | |
| 261 | return 0; |
| 262 | } |
| 263 | |
| 264 | void SQLiteObject::CloseDatabase() |
| 265 | { |
no test coverage detected