[wp-trac] [WordPress Trac] #57185: Usage of a direct database call is discouraged
WordPress Trac
noreply at wordpress.org
Wed Nov 23 22:44:31 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: Database | Version:
Severity: normal | Resolution:
Keywords: | Focuses:
--------------------------+------------------------------
Changes (by sabernhardt):
* component: General => Database
Old description:
> 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
New description:
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
--
Comment:
Related: [https://wordpress.org/support/topic/usage-of-a-direct-database-
call-is-discouraged/ WordPress.org support topic] and
[https://wordpress.stackexchange.com/questions/181851/avoiding-usage-of-a
-direct-database-call-is-discouraged#answer-181859 StackExchange answer]
--
Ticket URL: <https://core.trac.wordpress.org/ticket/57185#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list