I am trying to delete Id on SQL not working i got string(87) "DELETE FROM wp_availability WHERE
id IN (Array,Array,Array,Array)"
get this kind value
if ( count( $remove ) > 0 ) {
$removeSQL = "DELETE FROM " . $this->table . " WHERE `id` IN (" .
implode( ",", $remove ) . ")";
if ( $wpdb->query( $removeSQL ) ) {
$saved = true;
}
}
Thanks in Advance
To expand on Vince0789
's answer...
$remove
looks to contain an array of arrays and not just an id
string.
For example, $remove
may be layed out as below;
[
[
'id' => 1,
'content' => "Foo"
],
[
'id' => 2,
'content' => "Bar"
],
]
What you will want to do is use array_column()
on the $remove
array to capture just the IDs from the array and then implode that new array and pass it to the query.
$to_remove = array_column($remove, 'id'); //assuming that id is the column you want
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.