本文整理汇总了Golang中github.com/lann/squirrel.SelectBuilder.PlaceholderFormat方法的典型用法代码示例。如果您正苦于以下问题:Golang SelectBuilder.PlaceholderFormat方法的具体用法?Golang SelectBuilder.PlaceholderFormat怎么用?Golang SelectBuilder.PlaceholderFormat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/lann/squirrel.SelectBuilder
的用法示例。
在下文中一共展示了SelectBuilder.PlaceholderFormat方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Query
func (q SqlQuery) Query(ctx context.Context, sql sq.SelectBuilder) (*sqlx.Rows, error) {
sql = sql.PlaceholderFormat(sq.Dollar)
query, args, err := sql.ToSql()
if err != nil {
return nil, errors.Wrap(err, 1)
}
return q.QueryRaw(ctx, query, args)
}
示例2: Get
// Get gets a single row returned by the provided sql builder into the provided dest.
// dest must be a non-slice value of the correct record type.
func (q SqlQuery) Get(ctx context.Context, sql sq.SelectBuilder, dest interface{}) error {
sql = sql.PlaceholderFormat(sq.Dollar)
query, args, err := sql.ToSql()
if err != nil {
return errors.Wrap(err, 1)
}
return q.GetRaw(ctx, query, args, dest)
}
示例3: Get
func (q SqlQuery) Get(ctx context.Context, sql sq.SelectBuilder, dest interface{}) error {
db := sqlx.NewDb(q.DB, "postgres")
sql = sql.PlaceholderFormat(sq.Dollar)
query, args, err := sql.ToSql()
if err != nil {
return err
}
return db.Get(dest, query, args...)
}
示例4: Select
func (q SqlQuery) Select(ctx context.Context, sql sq.SelectBuilder, dest interface{}) error {
db := sqlx.NewDb(q.DB, "postgres")
sql = sql.PlaceholderFormat(sq.Dollar)
query, args, err := sql.ToSql()
if err != nil {
return err
}
log.WithField(ctx, "sql", query).Info("Executing query")
return db.Select(dest, query, args...)
}