最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

wp query - Issue with $wpdb->prepare() in Plugin Check

programmeradmin3浏览0评论

I'm updating a WordPress plugin and using Plugin Check to detect errors. I'm getting the following error:

ERROR WordPress.DB.PreparedSQL.NotPrepared Use placeholders and $wpdb->prepare(); found $query

But my query already uses $wpdb->prepare(). Here’s my code:

<?php
$query = 'SELECT * FROM ' . $wpdb->base_prefix . "picks WHERE pick_result <> '' AND tipster_id = %d";

if (!empty($where)) {
    $query .= ' ' . esc_sql($where);
}
if (!empty($order)) {
    $query .= ' ' . esc_sql($order);
}
if (!empty($limits)) {
    $query .= ' ' . esc_sql($limits);
}

$tipster_picks = $wpdb->get_results($wpdb->prepare($query, $tipster), ARRAY_A);

Does anyone know why Plugin Check is flagging this as an error? Is there something wrong with how I'm handling $where, $order, or $limits?

Thanks in advance!

发布评论

评论列表(0)

  1. 暂无评论