[wp-trac] [WordPress Trac] #11100: delete_post_meta_by_key() is currently broken

WordPress Trac noreply at wordpress.org
Sat Jun 15 01:39:04 UTC 2013


#11100: delete_post_meta_by_key() is currently broken
--------------------------+---------------------
 Reporter:  Viper007Bond  |       Owner:  westi
     Type:  defect (bug)  |      Status:  closed
 Priority:  normal        |   Milestone:  2.9
Component:  Database      |     Version:  2.9
 Severity:  normal        |  Resolution:  fixed
 Keywords:  has-patch     |
--------------------------+---------------------

Comment (by Ninos Ego):

 I found this ticket after I searched for a solution with escaping in IN
 operators. I think the solution in [12156] is very nice. But if you have
 nothing in your array, you get a Database error. So here's my solution :)
 {{{
 $in = count($postmetaids) ? implode( ',', array_fill(1,
 count($postmetaids), '%d')) : 'NULL';
 $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->postmeta WHERE meta_id
 IN($in)", $postmetaids ));
 }}}

--
Ticket URL: <http://core.trac.wordpress.org/ticket/11100#comment:5>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list