mirror of
https://github.com/vlang/v.git
synced 2025-09-14 06:52:36 +03:00
orm: redesign orm (re-write it in V) (#10353)
This commit is contained in:
parent
ad41cd5c6f
commit
26db3b0995
23 changed files with 2350 additions and 1693 deletions
|
@ -19,6 +19,11 @@ pub enum ConnectionFlag {
|
|||
client_remember_options = C.CLIENT_REMEMBER_OPTIONS
|
||||
}
|
||||
|
||||
struct SQLError {
|
||||
msg string
|
||||
code int
|
||||
}
|
||||
|
||||
// TODO: Documentation
|
||||
pub struct Connection {
|
||||
mut:
|
||||
|
@ -46,7 +51,7 @@ pub fn (mut conn Connection) connect() ?bool {
|
|||
// query - make an SQL query and receive the results.
|
||||
// `query()` cannot be used for statements that contain binary data;
|
||||
// Use `real_query()` instead.
|
||||
pub fn (mut conn Connection) query(q string) ?Result {
|
||||
pub fn (conn Connection) query(q string) ?Result {
|
||||
if C.mysql_query(conn.conn, q.str) != 0 {
|
||||
return error_with_code(get_error_msg(conn.conn), get_errno(conn.conn))
|
||||
}
|
||||
|
@ -127,7 +132,7 @@ pub fn (conn &Connection) tables(wildcard string) ?[]string {
|
|||
pub fn (conn &Connection) escape_string(s string) string {
|
||||
unsafe {
|
||||
to := malloc_noscan(2 * s.len + 1)
|
||||
C.mysql_real_escape_string_quote(conn.conn, to, s.str, s.len, `\'`)
|
||||
C.mysql_real_escape_string(conn.conn, to, s.str, s.len)
|
||||
return to.vstring()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue