admin管理员组文章数量:1356808
I'm traying to select something from database and I have to use 2 bind params. With one param it works but with two i get this error "Undefined binding(s) detected when piling RAW query" error and "Expected 1 bindings, saw 2" in nodejs console.
How to use 2nd bind param?
Code that works:
knex.with('with_alias', knex.raw('select * from "lyrics" where "for_id" = "1" and "var" = ?', var)).select('*').from('with_alias')
I also tried but it didn't worked
knex.with('with_alias', knex.raw('select * from "lyrics" where "for_id" = ? and "var" = ?', var1, var2)).select('*').from('with_alias')
Thanks for help and sorry for bad english!
I'm traying to select something from database and I have to use 2 bind params. With one param it works but with two i get this error "Undefined binding(s) detected when piling RAW query" error and "Expected 1 bindings, saw 2" in nodejs console.
How to use 2nd bind param?
Code that works:
knex.with('with_alias', knex.raw('select * from "lyrics" where "for_id" = "1" and "var" = ?', var)).select('*').from('with_alias')
I also tried but it didn't worked
knex.with('with_alias', knex.raw('select * from "lyrics" where "for_id" = ? and "var" = ?', var1, var2)).select('*').from('with_alias')
Thanks for help and sorry for bad english!
Share Improve this question asked Jan 28, 2019 at 17:59 Pavel ProdanPavel Prodan 692 silver badges7 bronze badges1 Answer
Reset to default 7Try to pass two variables in an array:
knex.with('with_alias', knex.raw('select * from "lyrics" where "for_id" = ? and "var" = ?', [var1, var2])).select('*').from('with_alias')
It should work.
本文标签: javascriptHow to add two bind params in knexStack Overflow
版权声明:本文标题:javascript - How to add two bind params in knex? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743998382a2573407.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论