mirror of
https://github.com/astaxie/beego.git
synced 2024-12-23 00:00:50 +00:00
new query builder based on driver
This commit is contained in:
parent
c667895ce5
commit
f9a9b5a905
14
orm/qb.go
14
orm/qb.go
@ -14,6 +14,8 @@
|
||||
|
||||
package orm
|
||||
|
||||
import "errors"
|
||||
|
||||
type QueryBuilder interface {
|
||||
Select(fields ...string) QueryWriter
|
||||
From(tables ...string) QueryWriter
|
||||
@ -29,7 +31,15 @@ type QueryBuilder interface {
|
||||
String() string
|
||||
}
|
||||
|
||||
func NewQueryBuilder() (qb QueryBuilder) {
|
||||
qb = new(MySQLQueryBuilder)
|
||||
func NewQueryBuilder(driver string) (qb QueryBuilder, err error) {
|
||||
if driver == "mysql" {
|
||||
qb = new(MySQLQueryBuilder)
|
||||
} else if driver == "postgres" {
|
||||
err = errors.New("postgres querybuilder is not supported yet!")
|
||||
} else if driver == "sqlite" {
|
||||
err = errors.New("sqlite querybuilder is not supported yet!")
|
||||
} else {
|
||||
err = errors.New("unknown driver for query builder!")
|
||||
}
|
||||
return
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user