platform.go 541 Bytes
package models

import (
	"database/sql"

	db "client/icesimba.ad/database"
)

type Platform struct {
	Id   int64
	Name string
}

type platform struct {
	Id   sql.NullInt64
	Name sql.NullString
}

func QueryPlatformByName(name string) (out Platform, err error) {
	sqlQu := "select platform_id from ice_platform where platform_name=? limit 1"
	platNull := platform{}
	err = db.SqlDB.QueryRow(sqlQu, name).Scan(
		&platNull.Id,
	)
	if err != nil {
		return
	}
	if platNull.Id.Valid {
		out.Id = platNull.Id.Int64
	}
	out.Name = name
	return
}