This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func query(db *sql.DB, name []string) { | |
query := fmt.Sprint("select id, name, grade from students ") | |
where := "where " | |
params := interface{}{} | |
if len(names) > 0 { | |
q, p := prepareStringArray(names, len(params)) | |
params = append(params, p...) | |
where += fmt.Sprintf(`AND t.id IN (%v) `, q) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func query(db *sql.DB, name []string) { | |
query := fmt.Sprint("select id, name, grade from students ") | |
where := "where " | |
params := interface{}{} | |
if len(names) > 0 { | |
where += `f.id IN ('` + strings.Join(names, "','") + `') ` | |
} | |
query = query + where |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func query(db *sql.DB, orderBy []string) { | |
query := fmt.Sprint("select id, name, grade from students ") | |
paging := "" | |
if len(opt.OrderBy) > 0 { | |
validColumn := map[string]string{ | |
"id": "id", | |
"created_at": "created_at", | |
} | |
paging = sanitizeOrderBy(orderBy, validColumn, paging) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func query(db *sql.DB, orderBy []string) { | |
query := fmt.Sprint("select id, name, grade from students ") | |
paging := "" | |
if len(opt.OrderBy) > 0 { | |
paging += `ORDER BY ` + strings.Join(orderBy, ",") + ` ` | |
} | |
query = query + paging | |
_, err := db.Query(query) | |
if err != nil { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func query(db *sql.DB, name string) { | |
query := fmt.Sprint("select id, name, grade from students ") | |
where := "where " | |
params := interface{}{} | |
if name != "" { | |
params = append(params, name) | |
where += "name=$%d",len(params)" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func query(db *sql.DB, name string) { | |
query := fmt.Sprint("select id, name, grade from students where name = '%s'", name) | |
_, err := db.Query(query) | |
if err != nil { | |
fmt.Println(err.Error()) | |
return | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func query(db *sql.DB, name []string) { | |
query := fmt.Sprint("select id, name, grade from students ") | |
where := "where " | |
params := interface{}{} | |
if len(names) > 0 { | |
q, p := prepareStringArray(names, len(params)) | |
params = append(params, p...) | |
where += fmt.Sprintf(`AND t.id IN (%v) `, q) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func query(db *sql.DB, name []string) { | |
query := fmt.Sprint("select id, name, grade from students ") | |
where := "where " | |
params := interface{}{} | |
if len(names) > 0 { | |
q, p := prepareStringArray(names, len(params)) | |
params = append(params, p...) | |
where += fmt.Sprintf(`AND t.id IN (%v) `, q) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
🌞 Morning 116 commits ██████▋░░░░░░░░░░░░░░ 32.0% | |
🌆 Daytime 155 commits ████████▉░░░░░░░░░░░░ 42.8% | |
🌃 Evening 86 commits ████▉░░░░░░░░░░░░░░░░ 23.8% | |
🌙 Night 5 commits ▎░░░░░░░░░░░░░░░░░░░░ 1.4% |