$wpdb->prepare referencing a const without a coding guideline warning


I have defined my database table names as constants in a base class and use them throughout my code.

protected const MAP_KEY_TABLE = 'eds_map_keys';

If I use them like this I get a warning to use place holders.

$keys   = $wpdb->get_results(
        'SELECT * FROM ' . self::MAP_KEY_TABLE . ' WHERE key_type = "map_key"',
    $mapkey = $keys[0]->key_value;

if I use place holders like this I get a warning that:

"message": "Complex placeholders used for values in the query string in $wpdb->prepare() will NOT be quoted automagically. Found: %1s."

I’d really like to get rid of the messages about coding style but have been stuck on this one for a while. Any suggestions greatly appreciated.

xsoftie 1 year 2023-02-18T16:03:27-05:00 0 Answers 0 views 0

Leave an answer