v/vlib/mysql/utils.v

27 lines
548 B
V
Raw Normal View History

module mysql
2021-01-09 09:40:21 +01:00
// get_error_msg - returns error message from MySQL instance.
fn get_error_msg(conn &C.MYSQL) string {
2021-01-09 09:40:21 +01:00
return unsafe { C.mysql_error(conn).vstring() }
}
2021-01-09 09:40:21 +01:00
// get_errno - returns error number from MySQL instance.
fn get_errno(conn &C.MYSQL) int {
return C.mysql_errno(conn)
}
2021-01-09 09:40:21 +01:00
// resolve_nil_str - returns an empty string if passed value is a nil pointer.
2022-04-15 17:25:45 +02:00
fn resolve_nil_str(ptr &u8) string {
2020-10-19 20:11:04 +02:00
if isnil(ptr) {
return ''
}
2021-01-09 09:40:21 +01:00
return unsafe { ptr.vstring() }
}
[inline]
2022-04-15 17:25:45 +02:00
fn mystring(b &u8) string {
unsafe {
return b.vstring()
}
}