mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
mysql: make the struct public & update some code
This commit is contained in:
parent
c0bb88dfb0
commit
33793a869f
@ -3,36 +3,31 @@ module mysql
|
||||
#flag -lmysqlclient
|
||||
#include <mysql.h>
|
||||
|
||||
struct DB {
|
||||
conn *C.MYSQL
|
||||
pub struct DB {
|
||||
conn &C.MYSQL
|
||||
}
|
||||
|
||||
struct Result {
|
||||
result *C.MYSQL_RES
|
||||
pub struct Result {
|
||||
result &C.MYSQL_RES
|
||||
}
|
||||
|
||||
struct Row {
|
||||
pub struct Row {
|
||||
pub mut:
|
||||
vals []string
|
||||
}
|
||||
|
||||
// C
|
||||
|
||||
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
|
||||
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)
|
||||
|
||||
pub fn connect(server, user, passwd, dbname string) DB {
|
||||
conn := C.mysql_init(0)
|
||||
|
Loading…
Reference in New Issue
Block a user