MCPcopy Create free account
hub / github.com/HaxeFoundation/hxcpp / _hx_sqlite_request

Function _hx_sqlite_request

src/hx/libs/sqlite/Sqlite.cpp:240–272  ·  view source on GitHub ↗

request : 'db -> sql:string -> 'result Executes the SQL request and returns its result **/

Source from the content-addressed store, hash-verified

238 <doc>Executes the SQL request and returns its result</doc>
239**/
240Dynamic _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

Callers

nothing calls this directly

Calls 8

getDatabaseFunction · 0.85
ThrowFunction · 0.85
utf8_strMethod · 0.80
StringClass · 0.50
createMethod · 0.45
setResultMethod · 0.45

Tested by

no test coverage detected