Quantcast
Channel: Question and Answer » wpdb
Viewing all articles
Browse latest Browse all 44

$wpdb-prepare : Do I have to bind a parameter to the table name?

$
0
0

I only do a SELECT on a whole table – and the table is defined in a variable:

$table = $wpdb->prefix . 'members';

Do I have to bind a parameter to this variable?

This caused an error:

$result = $wpdb->get_results($wpdb->prepare("SELECT * FROM %s", $table, ARRAY_A));

But if I skip the “%s”, this gives an error as well:

$result = $wpdb->get_results($wpdb->prepare("SELECT * FROM $table", ARRAY_A));

Should I skip “prepare” in this case?


Viewing all articles
Browse latest Browse all 44

Trending Articles