Example code for deleting a single row in a WordPress table by targeting one data:
[php]
$wpdb->delete(
‘wp_table’, // table to delete from
array(
‘column1’ => 123 // value in column to target for deletion
),
array(
‘%d’ // format of value being targeted for deletion
)
);
[/php]
You probably want to do something more complicated than delete a row. In that case, you will have to use {php}$wpbd->query{/php} to pass a SQL function:
[php]
$wpdb->query(
$wpdb->prepare(
‘
DELETE wp_table
WHERE column1 = %d
AND column2 = %s
‘,
13, ‘jim’
)
);
[/php]
Share/Ask