PHP Snippet 1:
function vendor_module_remove_dealer($data)
{
global $wpdb;
$sql = 'DELETE FROM `'. $wpdb->prefix .'my_table` WHERE `primary_id` = %d;';
try {
$wpdb->query($wpdb->prepare($sql, array($data['primary-id'])));
return true;
} catch (Exception $e) {
return 'Error! '. $wpdb->last_error;
}
}
PHP Snippet 2:
global $wpdb;
$id = (int) wp_get_current_user()->ID;
$time = (int) '4';
$table_name = 'testtable';
$wpdb->show_errors();
$wpdb->delete( $table_name, array( 'user_id' => $id, 'timeMin' => $time), array('%d','%d'));
$wpdb->print_error();
PHP Snippet 3:
global $wpdb;
$id = (int) wp_get_current_user()->ID;
$time = (int) $_POST['umjp_time'];
$table_name = $wpdb->prefix . 'table_name';
if (!empty($id))
{
$wpdb->query($wpdb->prepare("DELETE FROM $table_name WHERE user_id IN($id)"));
}