mirror of
https://github.com/vlang/v.git
synced 2025-09-13 22:42:26 +03:00
orm: use errcode comparisons, instead of strcmp(sqlite3_errmsg,msg)
This commit is contained in:
parent
581603f2bd
commit
d3e676bdc1
4 changed files with 13 additions and 7 deletions
|
@ -37,6 +37,7 @@ fn C.sqlite3_step() int
|
|||
fn C.sqlite3_prepare_v2()
|
||||
fn C.sqlite3_finalize()
|
||||
fn C.sqlite3_column_count(voidptr) int
|
||||
fn C.sqlite3_errstr(int) charptr
|
||||
|
||||
// Opens the connection with a database.
|
||||
pub fn connect(path string) ?DB {
|
||||
|
@ -58,7 +59,10 @@ fn (db DB) init_stmt(query string) &C.sqlite3_stmt {
|
|||
|
||||
// Only for V ORM
|
||||
fn get_int_from_stmt(stmt &C.sqlite3_stmt) int {
|
||||
C.sqlite3_step(stmt)
|
||||
x := C.sqlite3_step(stmt)
|
||||
if x != C.SQLITE_OK && x != C.SQLITE_DONE {
|
||||
C.puts( C.sqlite3_errstr(x) )
|
||||
}
|
||||
res := C.sqlite3_column_int(stmt, 0)
|
||||
C.sqlite3_finalize(stmt)
|
||||
return res
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue