Exemplo n.º 1
0
// CategoryById получить категорию по ID
func CategoryById(id int) (map[string]string, error) {

	app := webapp.GetApplication()
	res, err := app.DB.Query("SELECT * FROM content_categories WHERE id = ?", id)
	if len(res) != 1 {
		err = errors.New("Not found in database")
		return nil, err
	}

	return res[0], err
}
Exemplo n.º 2
0
// CategoryByUrl получить категорию по alias (sef ссылка)
func CategoryByUrl(url string) (map[string]string, error) {

	app := webapp.GetApplication()
	url_crc32 := crc32.ChecksumIEEE([]byte(url))
	res, err := app.DB.Query("SELECT * FROM content_categories WHERE hash_url_crc32 = ? and url = ?", url_crc32, url)
	if len(res) != 1 {
		err = errors.New("Not found in database")
		return nil, err
	}

	return res[0], err
}
Exemplo n.º 3
0
func main() {
	log.Println("Server is preparing to start")
	Application := app.GetApplication()

	if Application.Config.Site.Disabled {
		log.Println("Site is disabled")
		Application.Routes(app.MapRoutes{{"/": handlers.HandleDisabled{}}})
	} else {
		Application.Routes(app.MapRoutes{
			{"/": handlers.HandleHome{}},
			//"/else": handlers.HandleElse{},
			{"/{url:.*}": handlers.Handle404{}},
		})
	}

	Application.Run()
	log.Println("Exit")
}
Exemplo n.º 4
0
// TableRowById получить таблицу по ID
func TableRowById(tableName string, id int) ([]map[string]string, error) {

	res, err := webapp.GetApplication().DB.Query("SELECT * FROM ? WHERE id = ?", tableName, id)

	return res, err
}