Can’t pass variable in wordpress wpdb->get_results

As you can see in the Codex pages the get_results doesn’t provide the functionality to add a value parameter in the method:

$wpdb->get_results('query', output_type);

output_type has the following description:

One of four pre-defined constants. Defaults to OBJECT. See SELECT a Row and its examples for more information.

  • OBJECT – result will be output as a numerically indexed array of row objects.
  • OBJECT_K – result will be output as an associative array of row objects, using first column’s values as keys (duplicates will be discarded).
  • ARRAY_A – result will be output as an numerically indexed array of associative arrays, using column names as keys.
  • ARRAY_N – result will be output as a numerically indexed array of numerically indexed arrays.

You could use the following:

$results = $wpdb->get_results(
  $wpdb->prepare(
    "
    SELECT *
     FROM tblTast
     WHERE manufacturer = %d
    ",
    $taxonomies
  )
);

if ( $results ) {
  foreach ( $results as $pointer ) {
    /* your code here */
  }
}

We’ll add the ‘prepare’ method to make sure we’re not dealing with an illegal operation or any illegal characters

See the Codex for more information.