mysql: make the struct public & update some code

pull/2956/head
Don Alfons Nisnoni 2019-12-02 22:26:58 +08:00 committed by Alexander Medvednikov
parent c0bb88dfb0
commit 33793a869f
1 changed files with 16 additions and 21 deletions

View File

@ -3,36 +3,31 @@ module mysql
#flag -lmysqlclient #flag -lmysqlclient
#include <mysql.h> #include <mysql.h>
struct DB { pub struct DB {
conn *C.MYSQL conn &C.MYSQL
} }
struct Result { pub struct Result {
result *C.MYSQL_RES result &C.MYSQL_RES
} }
struct Row { pub struct Row {
pub mut: pub mut:
vals []string vals []string
} }
// C struct C.MYSQL
struct C.MYSQL_RES
struct C.MYSQL { }
struct C.MYSQL_RES { }
fn C.mysql_init(mysql *C.MYSQL) *C.MYSQL
fn C.mysql_real_connect(mysql *C.MYSQL, host byteptr, user byteptr, passwd byteptr, db byteptr, port u32, unix_socket byteptr, clientflag u64) *C.MYSQL
fn C.mysql_query(mysql *C.MYSQL, q byteptr) int
fn C.mysql_error(mysql *C.MYSQL) byteptr
fn C.mysql_num_fields(res *C.MYSQL_RES) int
fn C.mysql_store_result(mysql *C.MYSQL) *C.MYSQL_RES
fn C.mysql_fetch_row(res *C.MYSQL_RES) &byteptr
fn C.mysql_free_result(res *C.MYSQL_RES)
fn C.mysql_close(sock *C.MYSQL)
// V
fn C.mysql_init(mysql &C.MYSQL) &C.MYSQL
fn C.mysql_real_connect(mysql &C.MYSQL, host byteptr, user byteptr, passwd byteptr, db byteptr, port u32, unix_socket byteptr, clientflag u64) &C.MYSQL
fn C.mysql_query(mysql &C.MYSQL, q byteptr) int
fn C.mysql_error(mysql &C.MYSQL) byteptr
fn C.mysql_num_fields(res &C.MYSQL_RES) int
fn C.mysql_store_result(mysql &C.MYSQL) &C.MYSQL_RES
fn C.mysql_fetch_row(res &C.MYSQL_RES) &byteptr
fn C.mysql_free_result(res &C.MYSQL_RES)
fn C.mysql_close(sock &C.MYSQL)
pub fn connect(server, user, passwd, dbname string) DB { pub fn connect(server, user, passwd, dbname string) DB {
conn := C.mysql_init(0) conn := C.mysql_init(0)