When should I use $wpdb->prepare, if at all?

后端 未结 1 889
轮回少年
轮回少年 2021-01-26 17:51

I have a hard time figuring out if I should be using $wpdb->prepare on my database queries in WordPress to prevent things such as SQL injection.

The $wpd

1条回答
  •  北恋
    北恋 (楼主)
    2021-01-26 18:36

    As I understand - the methods those have placeholders for query parameters ($wpdb->insert(), $wpdb->update(), $wpdb->delete()) don't need the $wpdb->prepare() method, and they are already safe.

    But the others - those don't have placeholders, need additional sql escaping.

    0 讨论(0)
提交回复
热议问题