Skip to content

自定义查询


query()

如果上面的ORM链式操作均满足不了你,那可以用这个直接写sql语句查询

  • @param sql 查询语句,防止注入请用?占位
  • @param values 匹配?的值
  • @param isShowSql 是否打印最终执行的SQL语句,默认不打印
  • (sql: string, values: (number | string)[] = [], isShowSql: boolean = false)

query()

Db().query('select * from user where id = ?', [1])
Db().query('select * from user where id = ?', [1])

最终的SQL语句为:

SELECT * FROM user WHERE id = 1
SELECT * FROM user WHERE id = 1

备案号:冀ICP备20015584号-2