[wp-trac] [WordPress Trac] #57185: Usage of a direct database call is discouraged

WordPress Trac noreply at wordpress.org
Wed Nov 23 12:06:56 UTC 2022


#57185: Usage of a direct database call is discouraged
--------------------------+-----------------------------
 Reporter:  pnnande       |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  General       |    Version:
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 Hello,

 I am simply inserting a row into a table.
 global $wpdb;

 $table_consent = $wpdb->prefix . 'gjmji_consent';

 $wpdb->insert(
         $table_consent,
         array(
                 'email'    => sanitize_email( wp_unslash( $_GET['gjmp4wp-
 email'] ) ),
                 'language' => WPMJI_LANGUAGE_CURRENT,
         ),
 );

 My code sniffer (wpcs) is telling me that “Usage of a direct database call
 is discouraged.” I tried something with prepare a while back but couldn’t
 figure it out. Is that the way to go?

 How do I do this properly?

 Thanks!
 Pragati

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/57185>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list