request : 'db -> sql:string -> 'result Executes the SQL request and returns its result **/
| 238 | <doc>Executes the SQL request and returns its result</doc> |
| 239 | **/ |
| 240 | Dynamic _hx_sqlite_request(Dynamic handle,String sql) |
| 241 | { |
| 242 | database *db = getDatabase(handle); |
| 243 | |
| 244 | int byteLength = 0; |
| 245 | const char * sqlStr = sql.utf8_str(0, true, &byteLength); |
| 246 | sqlite3_stmt *statement = 0; |
| 247 | const char *tl = 0; |
| 248 | __hxcpp_enter_gc_free_zone(); |
| 249 | int err = sqlite3_prepare(db->db,sqlStr,byteLength,&statement,&tl); |
| 250 | __hxcpp_exit_gc_free_zone(); |
| 251 | if (err != SQLITE_OK) |
| 252 | { |
| 253 | hx::Throw( HX_CSTRING("Sqlite error in ") + sql + HX_CSTRING(" : ") + |
| 254 | String(sqlite3_errmsg(db->db) ) ); |
| 255 | } |
| 256 | if( *tl ) |
| 257 | { |
| 258 | __hxcpp_enter_gc_free_zone(); |
| 259 | sqlite3_finalize(statement); |
| 260 | __hxcpp_exit_gc_free_zone(); |
| 261 | hx::Throw(HX_CSTRING("Cannot execute several SQL requests at the same time")); |
| 262 | } |
| 263 | |
| 264 | int i,j; |
| 265 | |
| 266 | result *r = new result(); |
| 267 | r->create(db->db, statement,sql); |
| 268 | |
| 269 | db->setResult(r); |
| 270 | |
| 271 | return r; |
| 272 | } |
| 273 | |
| 274 | |
| 275 |
nothing calls this directly
no test coverage detected