like query with prepare wordpress 1

like query with prepare wordpress

$wpdb->prepare(" AND $wpdb->usermeta.meta_key = '{$wpdb->prefix}capabilities' AND $wpdb->usermeta.meta_value LIKE %s", '%' . $this->role . '%');

Here is what the above code is Doing:
1. It’s getting the usermeta table and the user table.
2. It’s joining the usermeta table to the user table.
3. It’s getting the usermeta table’s meta_key and meta_value columns.
4. It’s getting the user table’s ID, user_login, user_nicename, display_name, and user_email columns.
5. It’s getting the usermeta table’s meta_key column and comparing it to the string ‘{$wpdb->prefix}capabilities’.
6. It’s getting the usermeta table’s meta_value column and comparing it to the string ‘%’ . $this->role . ‘%’.

The above code is a bit confusing, but it’s basically saying, “Get the usermeta table and the user table. Join the usermeta table to the user table. Get the usermeta table’s meta_key and meta_value columns. Get the user table’s ID, user_login, user_nicename, display_name, and user_email columns. Get the usermeta table’s meta_key column and compare it to the string ‘{$wpdb->prefix}capabilities’. Get the usermeta table’s meta_value column and compare it to the string ‘%’ . $this->role . ‘%’.”

The above code is a bit confusing, but it’s basically saying, “Get the usermeta table and the user table. Join the usermeta table to the user table. Get the usermeta table’s meta_key and meta_value columns. Get the user table’s ID, user_login, user_nicename, display_name, and user_email columns. Get the usermeta table’s meta_key column and compare it to the string ‘{$wpdb->prefix}capabilities’. Get the usermeta table’s meta_value column and compare it to the string ‘%’ . $this->role . ‘%’.”

The above code is a bit confusing, but it’s basically saying, “Get the usermeta table and the user table. Join the usermeta table to the user table. Get the usermeta table’s meta_key and meta_value columns. Get the user table’s ID, user_login, user_nicename, display_name, and user_email columns. Get the usermeta table’s meta_key column and compare it to the string ‘{$wpdb->prefix}capabilities’. Get the usermeta table’s meta_value column and compare it to the string ‘%’ . $this->role . ‘%’.”

The above code is a bit confusing, but it’s basically saying, “Get the usermeta table and the user table. Join the usermeta table to the user table. Get the usermeta table’s meta_key and meta_value columns. Get the user table’s ID, user_login, user_nicename, display_name, and user_email columns. Get the usermeta table’s meta_key column and compare it to the string ‘{$wpdb->prefix}capabilities’. Get the usermeta table’s meta_value column and compare it to the string ‘%’ . $this->role . ‘%’.”

The above code is a bit confusing, but it’s basically saying, “Get the usermeta table and the user table. Join the usermeta table to the user table. Get the usermeta table’s meta_key and meta_value columns. Get the user table’s ID, user_login, user_nicename, display_name, and user_email columns. Get the usermeta table’s meta_key column and compare it to the string ‘{$wpdb->prefix}capabilities’. Get the usermeta table’s meta_value column and compare it to the string ‘%’

Similar Posts