mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
This commit is contained in:
@@ -153,14 +153,11 @@ pub fn (db Connection) delete(table string, where orm.QueryData) ! {
|
||||
}
|
||||
|
||||
// last_id is used internally by V's ORM for post-processing `INSERT ` queries
|
||||
pub fn (db Connection) last_id() orm.Primitive {
|
||||
pub fn (db Connection) last_id() int {
|
||||
query := 'SELECT last_insert_id();'
|
||||
id := db.query(query) or {
|
||||
Result{
|
||||
result: 0
|
||||
}
|
||||
}
|
||||
return orm.Primitive(id.rows()[0].vals[0].int())
|
||||
id := db.query(query) or { return 0 }
|
||||
|
||||
return id.rows()[0].vals[0].int()
|
||||
}
|
||||
|
||||
// DDL (table creation/destroying etc)
|
||||
|
@@ -51,10 +51,10 @@ pub fn (db DB) delete(table string, where orm.QueryData) ! {
|
||||
}
|
||||
|
||||
// last_id is used internally by V's ORM for post-processing `INSERT ` queries
|
||||
pub fn (db DB) last_id() orm.Primitive {
|
||||
pub fn (db DB) last_id() int {
|
||||
query := 'SELECT LASTVAL();'
|
||||
id := db.q_int(query) or { 0 }
|
||||
return orm.Primitive(id)
|
||||
|
||||
return db.q_int(query) or { 0 }
|
||||
}
|
||||
|
||||
// DDL (table creation/destroying etc)
|
||||
|
@@ -71,10 +71,10 @@ pub fn (db DB) delete(table string, where orm.QueryData) ! {
|
||||
}
|
||||
|
||||
// last_id is used internally by V's ORM for post-processing `INSERT ` queries
|
||||
pub fn (db DB) last_id() orm.Primitive {
|
||||
pub fn (db DB) last_id() int {
|
||||
query := 'SELECT last_insert_rowid();'
|
||||
id := db.q_int(query)
|
||||
return orm.Primitive(id)
|
||||
|
||||
return db.q_int(query)
|
||||
}
|
||||
|
||||
// DDL (table creation/destroying etc)
|
||||
|
Reference in New Issue
Block a user