如何将多个参数绑定到 PHP 准备好的语句?
"SELECT id as Id from dbTable WHERE code = ? AND CURDATE() BETWEEN
start_date AND end_date AND offerId IN ('12321', '12124')";
//Passing arguments for the query
$args = array_merge(array(51342),$offerid);
//Execute the prepared query
$statement->execute($args);
现在数组(51342)表示代码+值的组合,除了我的数据库有值、代码列之外,所以我想要一个逻辑上看起来像这样的查询:
"SELECT id as Id from dbTable WHERE code and value
//(Note here I do not know the syntax,
//what am looking at is (code+value = ?), please advise on query) = ?
AND CURDATE() BETWEEN start_date AND end_date AND offerId IN ('12321', '12124')";
"SELECT id as Id from dbTable WHERE code = ? AND CURDATE() BETWEEN
start_date AND end_date AND offerId IN ('12321', '12124')";
//Passing arguments for the query
$args = array_merge(array(51342),$offerid);
//Execute the prepared query
$statement->execute($args);
Now array(51342) represents combination of code+value, aside my database has value, code columns and so I want a query which would look logically like:
"SELECT id as Id from dbTable WHERE code and value
//(Note here I do not know the syntax,
//what am looking at is (code+value = ?), please advise on query) = ?
AND CURDATE() BETWEEN start_date AND end_date AND offerId IN ('12321', '12124')";
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
刚刚在搜索中找到了一个:
虽然不确定这是否可以正常工作!
谢谢 !!!
Just got one in the search:
Not sure though this would work perfectly fine !!!
Thanks !!!