1 回答

TA貢獻2080條經(jīng)驗 獲得超4個贊
包中沒有轉(zhuǎn)義函數(shù),請參閱相關(guān)問題#18478(并且在使用數(shù)據(jù)庫抽象層時調(diào)用mysql特定的函數(shù)也不好)。database/sql
但它也不是必需的,因為您仍然可以在動態(tài)查詢中使用。只需將查詢參數(shù)與查詢一起動態(tài)構(gòu)建,如下所示:?
query := "SELECT vs.*, lm.nama_member" +
" FROM volks_shift vs LEFT JOIN list_member lm ON vs.id_m=lm.id_m" +
" WHERE vs.id_s=?"
params := []interface{}{id_s}
if status != "99" {
query += " AND vs.stats = '1'"
}
if cari != "" {
query += " AND (lm.title_member LIKE ? OR lm.nama_member LIKE ?)"
params = append(params, "%"+cari+"%", "%"+cari+"%")
}
rows, err := s.DB.QueryContext(ctx, query, params...)
- 1 回答
- 0 關(guān)注
- 76 瀏覽
添加回答
舉報