| 183 | } |
| 184 | |
| 185 | bool SQLiteObject::OpenDatabase(const char* filename) |
| 186 | { |
| 187 | // check to see if we already have an open database, and |
| 188 | // if so, close it. |
| 189 | CloseDatabase(); |
| 190 | |
| 191 | Con::printf("CALLING THE OLD OPEN DATABASE FUNCTION!!!!!!!!!!!!!!!!!!"); |
| 192 | |
| 193 | // We persist the error string so that the script may make a |
| 194 | // GetLastError() call at any time. However when we get |
| 195 | // ready to make a call which could result in a new error, |
| 196 | // we need to clear what we have to avoid a memory leak. |
| 197 | ClearErrorString(); |
| 198 | |
| 199 | S32 isOpen = sqlite3_open(filename, &m_pDatabase); |
| 200 | if (isOpen == SQLITE_ERROR) |
| 201 | { |
| 202 | // there was an error and the database could not |
| 203 | // be opened. |
| 204 | m_szErrorString = (char *)sqlite3_errmsg(m_pDatabase); |
| 205 | Con::executef(this, "2", "onOpenFailed()", m_szErrorString); |
| 206 | return false; |
| 207 | } |
| 208 | else |
| 209 | { |
| 210 | // database was opened without error |
| 211 | Con::executef(this, "1", "onOpened()"); |
| 212 | |
| 213 | //Now, for OpenSimEarth, load spatialite dll, so we can have GIS functions. |
| 214 | //S32 canLoadExt = sqlite3_load_extension(m_pDatabase,"mod_spatialite.dll",0,0); |
| 215 | //Con::printf("opened spatialite extension: %d",canLoadExt); |
| 216 | //Sigh, no luck yet. Cannot find function GeomFromText(). |
| 217 | } |
| 218 | return true; |
| 219 | } |
| 220 | |
| 221 | S32 SQLiteObject::ExecuteSQL(const char* sql) |
| 222 | { |
no test coverage detected