我正在尝试使用 WordPress $wpdb
删除 mySQL 表的最后一条记录。我试过这个:
global $wpdb;
$wpdb->delete('claps',array('orderby' => 'id desc limit 1'));
但是这不起作用。 $wpdb
变量运行良好,因为我之前已经完成了插入查询,所以问题出在删除查询中。有人可以告诉我这是如何在 WordPress 中完成的吗?
谢谢。
最佳答案
您的数组中可能有错误。 delete()
方法的第二个参数应该与 SQL 中的 WHERE 相关。您可以在这里找到更多信息:https://developer.wordpress.org/reference/classes/wpdb/delete/#parameters
$where
(array) (Required) A named array of WHERE clauses (in column => value pairs). Multiple clauses will be joined with ANDs. Both $where columns and $where values should be "raw". Sending a null value will create an IS NULL comparison - the corresponding format will be ignored in this case.
关于mysql - 删除WordPress表的最后一条记录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57108489/