mirror of
https://github.com/hanzoai/sqlbuilder.git
synced 2026-10-01 00:37:42 +00:00
refs #18. add new method ReplaceInto in InsertBuilder
This commit is contained in:
@@ -22,3 +22,19 @@ func ExampleInsertBuilder() {
|
||||
// INSERT INTO demo.user (id, name, status, created_at) VALUES (?, ?, ?, UNIX_TIMESTAMP(NOW())), (?, ?, ?, ?)
|
||||
// [1 Huan Du 1 2 Charmy Liu 1 1234567890]
|
||||
}
|
||||
|
||||
func ExampleInsertBuilder_replaceInto() {
|
||||
ib := NewInsertBuilder()
|
||||
ib.ReplaceInto("demo.user")
|
||||
ib.Cols("id", "name", "status", "created_at")
|
||||
ib.Values(1, "Huan Du", 1, Raw("UNIX_TIMESTAMP(NOW())"))
|
||||
ib.Values(2, "Charmy Liu", 1, 1234567890)
|
||||
|
||||
sql, args := ib.Build()
|
||||
fmt.Println(sql)
|
||||
fmt.Println(args)
|
||||
|
||||
// Output:
|
||||
// REPLACE INTO demo.user (id, name, status, created_at) VALUES (?, ?, ?, UNIX_TIMESTAMP(NOW())), (?, ?, ?, ?)
|
||||
// [1 Huan Du 1 2 Charmy Liu 1 1234567890]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user