Beispiel #1
0
// NewFence creates a new empty fence.
//
// Note that a DBProxy is Squirrel's interface
// that describes most sql.DB-like things.
//
// Flavor may be one of 'mysql', 'postgres'. Other DBs may
// work, but are untested.
func NewFence(db squirrel.DBProxyBeginner, dbFlavor string) *Fence {
	f := new(Fence)
	f.builder = squirrel.StatementBuilder.RunWith(db)

	// For Postgres we convert '?' to '$N' placeholders.
	if dbFlavor == "postgres" {
		f.builder = f.builder.PlaceholderFormat(squirrel.Dollar)
	}

	f.rec = structable.New(db, dbFlavor).Bind(FenceTable, f)

	return f
}
Beispiel #2
0
// New makes and executes a new lua file
func New(name string, res http.ResponseWriter, req *http.Request, session *sessions.Session) (*lua.LState, error) {
	L := lua.NewState()
	/*generalModule := &general.Module{}
	L.PreloadModule("general", generalModule.Loader)
	characterModule := &character.Module{}

	L.PreloadModule("account", accountModule.Loader)
	utilModule := &util.Module{name, req, res}
	L.PreloadModule("util", utilModule.Loader)
	characterModule := &character.Module{}
	L.PreloadModule("character", characterModule.Loader)*/
	playerModule := &character.Module{
		structable.New(database.Lua, "mysql"),
	}
	L.PreloadModule("character", playerModule.Loader)
	accountModule := &account.Module{
		session,
		structable.New(database.Lua, "mysql"),
	}
	L.PreloadModule("account", accountModule.Loader)
	err := L.DoFile(config.Parser.Style.Template + "/pages/" + name + ".lua")
	return L, err
}
Beispiel #3
0
// NewUser creates a new Structable wrapper for a user.
//
// Of particular importance, watch how we intialize the Recorder.
func NewUser(db squirrel.DBProxyBeginner, dbFlavor string) *User {
	u := new(User)
	u.Recorder = structable.New(db, dbFlavor).Bind(UserTable, u)
	return u
}