1
0
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:
Zheng Yang 2014-09-08 17:56:55 +08:00
parent c667895ce5
commit f9a9b5a905

View File

@ -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
}