mysql: make the struct public & update some code
parent
c0bb88dfb0
commit
33793a869f
|
@ -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)
|
||||||
|
|
Loading…
Reference in New Issue