Wordpress Plugins - Does TRUNCATE work with wpdb?

Hi guys,

Basically I want to clear all data within a table (which I’ve created, it’s a caching table), but I’m having trouble deleting the data in the table. Here’s the function that runs when the required button is pressed in the back end:-

function wp_email_capture_truncate()
{
	global $wpdb;
	$table_name = $wpdb->prefix . "wp_email_capture_temp_members";
   	$sql = "TRUNCATE " . $table_name;
	$result = $wpdb->query($wpdb->prepare($sql));
}

Does wpdb allow the TRUNCATE FUNCTION? Or am I doing something really really stupid?

Thanks!

echo any [fphp]mysql_errno[/fphp] or [fphp]mysql_error[/fphp]

check this user has sufficient permission to delete/drop etc

look in your mysql error logs

To close this topic - yes it does. Though TRUNACATE doesn’t. Thanks Cups :slight_smile:

Ha! Brilliant, been there once or twice. :lol:

One of the many reasons to add SQL logging, a god-send.