Changeset 20087
- Timestamp:
- 09/28/08 11:03:03 (5 years ago)
- Location:
- lang/cplusplus/llv8call/trunk
- Files:
-
- 2 modified
-
ext/sqlite3/sqlite3.cc (modified) (3 diffs)
-
t/020_ext/06_sqlite.js (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
lang/cplusplus/llv8call/trunk/ext/sqlite3/sqlite3.cc
r20059 r20087 1 // based on Python DB API 2.0 2 // see also 3 // http://www.python.org/dev/peps/pep-0249/ 4 // http://www.python.jp/doc/contrib/peps/pep-0249.txt 5 1 6 #include "sqlite3.h" 2 7 #include <v8.h> … … 34 39 return str; 35 40 } 41 if ( sqlite3_exec(db, "BEGIN", NULL, NULL, NULL) != SQLITE_OK) { 42 return throw_errmsg(db); 43 } 36 44 args.This()->SetInternalField(0, External::New((void*)db)); 37 45 return args.This(); 46 } 47 48 static Handle<Value> _commit(const Arguments& args) { 49 assert_args(args, 0); 50 HandleScope handle_scope; 51 sqlite3 *db = handle<sqlite3>(args, 0); 52 if ( sqlite3_exec(db, "COMMIT", NULL, NULL, NULL) != SQLITE_OK) { 53 return throw_errmsg(db); 54 } 55 if ( sqlite3_exec(db, "BEGIN", NULL, NULL, NULL) != SQLITE_OK) { 56 return throw_errmsg(db); 57 } 58 return Undefined(); 59 } 60 61 static Handle<Value> _rollback(const Arguments& args) { 62 assert_args(args, 0); 63 HandleScope handle_scope; 64 sqlite3 *db = handle<sqlite3>(args, 0); 65 if ( sqlite3_exec(db, "ROLLBACK", NULL, NULL, NULL) != SQLITE_OK) { 66 return throw_errmsg(db); 67 } 68 return Undefined(); 38 69 } 39 70 … … 186 217 Handle<ObjectTemplate> ot = ft->InstanceTemplate(); 187 218 188 ot->Set(String::New("Close"), FunctionTemplate::New(_close)); 189 ot->Set(String::New("Cursor"), FunctionTemplate::New(_cursor)); 219 ot->Set(String::New("Close"), FunctionTemplate::New(_close)); 220 ot->Set(String::New("Commit"), FunctionTemplate::New(_commit)); 221 ot->Set(String::New("Rollback"), FunctionTemplate::New(_rollback)); 222 ot->Set(String::New("Cursor"), FunctionTemplate::New(_cursor)); 190 223 191 224 { -
lang/cplusplus/llv8call/trunk/t/020_ext/06_sqlite.js
r20061 r20087 29 29 db.Exec("INSERT INTO foo (id, name) VALUES (2, 'sato')"); 30 30 db.Exec("INSERT INTO foo (id, name) VALUES (3, 'kato')"); 31 db.Commit(); 32 db.Exec("INSERT INTO foo (id, name) VALUES (4, 'maesaka')"); // will rollback this 33 db.Rollback(); 31 34 32 35 (function (db) {
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)