在 wpdb->prepare() 中添加重复值
您好,我可以在 $wpdb->prepare 中添加重复值吗?
有以下 SQL 有
"SELECT
id,
MATCH (content) AGAINST('$search')
FROM table
WHERE MATCH(post_search) AGAINST('$search' IN BOOLEAN MODE)"
我对此
$wpdb->prepare("SELECT
id,
MATCH (content) AGAINST(%s)
FROM table
WHERE MATCH(post_search) AGAINST(%s IN BOOLEAN MODE)", $search_terms)
没有一种方法可以在不执行此操作的情况下执行此操作
$search_terms1 = $search_terms;
$search_terms2 = $search_terms;
$wpdb->prepare("SELECT
id,
MATCH (content) AGAINST(%s)
FROM table
WHERE MATCH(post_search) AGAINST(%s IN BOOLEAN MODE)", $search_terms1, $search_terms2)
Hi can I add a duplicate value in $wpdb->prepare.
I have the following SQL
"SELECT
id,
MATCH (content) AGAINST('$search')
FROM table
WHERE MATCH(post_search) AGAINST('$search' IN BOOLEAN MODE)"
to this
$wpdb->prepare("SELECT
id,
MATCH (content) AGAINST(%s)
FROM table
WHERE MATCH(post_search) AGAINST(%s IN BOOLEAN MODE)", $search_terms)
Is there a way of doing this without doing this
$search_terms1 = $search_terms;
$search_terms2 = $search_terms;
$wpdb->prepare("SELECT
id,
MATCH (content) AGAINST(%s)
FROM table
WHERE MATCH(post_search) AGAINST(%s IN BOOLEAN MODE)", $search_terms1, $search_terms2)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不使用
$wpdb
。 (对于这个问题,PDO
也是如此。)不过,您可以坚持传递初始变量,因为它不是通过引用传递的。Not using
$wpdb
. (Nor withPDO
, for that matter.) You could stick to passing the initial variable, though, since it's not passed by reference.为什么不使用与 SQL 中相同的方式:
Why not use the same as in SQL: