• In my plugin I use custom tables to store data. When I run some queries, my code looks like following example:

    $stmt = $wpdb->prepare("SELECT id, options, order_id FROM %i WHERE playlist_id = %d ORDER BY order_id", $media_table, $playlist_id);
    $medias = $wpdb->get_results($stmt, ARRAY_A);

    But when I run this with plugin check https://wordpress.org/plugins/plugin-check/ I will get an error. But the query is escaped, it just written in 2 lines.

    ERROR WordPress.DB.PreparedSQL.NotPreparedUse placeholders and $wpdb->prepare(); found $stmt

    • This topic was modified 3 weeks, 6 days ago by Imageteanco.
    • This topic was modified 3 weeks, 6 days ago by Imageteanco.
Viewing 1 replies (of 1 total)
  • Try:

    $medias = $wpdb->get_results(
    $wpdb->prepare(
    "SELECT id, options, order_id FROM %i WHERE playlist_id = %d ORDER BY order_id",
    $media_table,
    $playlist_id
    ),
    ARRAY_A
    );
Viewing 1 replies (of 1 total)

You must be logged in to reply to this topic.