Trying to pass a 2D array into a prepared WP SQL statement.
$idList
is the 2D array.
This is what I have:
$implodelist = ".implode(',', $idList).";
global $wpdb;
$result = $wpdb->get_results($wpdb->prepare("
SELECT wp_users.`user_email`,
wp_wp_pro_quiz_statistic.`correct_count`,
wp_wp_pro_quiz_statistic.`incorrect_count`,
wp_wp_pro_quiz_category.`category_name`
FROM wp_users
INNER JOIN wp_wp_pro_quiz_statistic_ref
ON wp_users.`ID` = wp_wp_pro_quiz_statistic_ref.`user_id`
INNER JOIN wp_wp_pro_quiz_statistic
ON wp_wp_pro_quiz_statistic_ref.`statistic_ref_id` = wp_wp_pro_quiz_statistic.`statistic_ref_id`
INNER JOIN wp_wp_pro_quiz_question
ON wp_wp_pro_quiz_statistic.`question_id` = wp_wp_pro_quiz_question.`id`
INNER JOIN wp_wp_pro_quiz_category
ON wp_wp_pro_quiz_question.`category_id` = wp_wp_pro_quiz_category.`category_id`
WHERE wp_users.`ID` IN %s", $implodelist));
But the array (as a string) does not seem to be passed correctly into the %s placeholder.
If I remove the prepared statement and have ".implode(',', $idList)."
in place of %s
, it works.
How can I pass the array values into the SQL statement?