most of add
This commit is contained in:
parent
a860c3ad70
commit
35406174a2
|
@ -48,6 +48,19 @@ func LoadCategories(db *sql.DB) {
|
|||
}
|
||||
}
|
||||
|
||||
func Add(db *sql.DB, name string, parent int) error {
|
||||
var err error
|
||||
if parent < 0 {
|
||||
err := db.Exec("INSERT INTO categories (name) VALUE ($1)", name)
|
||||
} else {
|
||||
err := db.Exec("INSERT INTO categories (name, parent_id) VALUE ($1, $2)", name, parent)
|
||||
}
|
||||
if err != nil {
|
||||
fmt.Println("Categories DB Error Add(): " , err)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (category *Category) ChangeParent(db *sql.DB, parent *Category) error {
|
||||
var err error
|
||||
if parent == nil {
|
||||
|
|
Loading…
Reference in New Issue