1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

db, json, time, term: change optional to result (#16201)

This commit is contained in:
yuyi
2022-10-26 16:26:28 +08:00
committed by GitHub
parent 2a7420f572
commit 992b502198
57 changed files with 340 additions and 340 deletions

View File

@@ -78,21 +78,21 @@ pub fn (db Connection) init_stmt(query string) Stmt {
}
}
pub fn (stmt Stmt) prepare() ? {
pub fn (stmt Stmt) prepare() ! {
res := C.mysql_stmt_prepare(stmt.stmt, stmt.query.str, stmt.query.len)
if res != 0 && stmt.get_error_msg() != '' {
return stmt.error(res)
}
}
pub fn (stmt Stmt) bind_params() ? {
pub fn (stmt Stmt) bind_params() ! {
res := C.mysql_stmt_bind_param(stmt.stmt, &C.MYSQL_BIND(stmt.binds.data))
if res && stmt.get_error_msg() != '' {
return stmt.error(1)
}
}
pub fn (stmt Stmt) execute() ?int {
pub fn (stmt Stmt) execute() !int {
res := C.mysql_stmt_execute(stmt.stmt)
if res != 0 && stmt.get_error_msg() != '' {
return stmt.error(res)
@@ -100,7 +100,7 @@ pub fn (stmt Stmt) execute() ?int {
return res
}
pub fn (stmt Stmt) next() ?int {
pub fn (stmt Stmt) next() !int {
res := C.mysql_stmt_next_result(stmt.stmt)
if res > 0 && stmt.get_error_msg() != '' {
return stmt.error(res)
@@ -116,7 +116,7 @@ pub fn (stmt Stmt) fetch_fields(res &C.MYSQL_RES) &C.MYSQL_FIELD {
return C.mysql_fetch_fields(res)
}
pub fn (stmt Stmt) fetch_stmt() ?int {
pub fn (stmt Stmt) fetch_stmt() !int {
res := C.mysql_stmt_fetch(stmt.stmt)
if res !in [0, 100] && stmt.get_error_msg() != '' {
return stmt.error(res)
@@ -124,7 +124,7 @@ pub fn (stmt Stmt) fetch_stmt() ?int {
return res
}
pub fn (stmt Stmt) close() ? {
pub fn (stmt Stmt) close() ! {
if !C.mysql_stmt_close(stmt.stmt) && stmt.get_error_msg() != '' {
return stmt.error(1)
}
@@ -222,14 +222,14 @@ pub fn (mut stmt Stmt) bind_res(fields &C.MYSQL_FIELD, dataptr []&u8, lens []u32
}
}
pub fn (mut stmt Stmt) bind_result_buffer() ? {
pub fn (mut stmt Stmt) bind_result_buffer() ! {
res := C.mysql_stmt_bind_result(stmt.stmt, &C.MYSQL_BIND(stmt.res.data))
if res && stmt.get_error_msg() != '' {
return stmt.error(1)
}
}
pub fn (mut stmt Stmt) store_result() ? {
pub fn (mut stmt Stmt) store_result() ! {
res := C.mysql_stmt_store_result(stmt.stmt)
if res != 0 && stmt.get_error_msg() != '' {
return stmt.error(res)