Opened 4 years ago
Closed 4 years ago
#57185 closed defect (bug) (invalid)
Usage of a direct database call is discouraged
| Reported by: | pnnande | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | Database | Version: | |
| Severity: | normal | Keywords: | |
| Cc: | Focuses: |
Description (last modified by )
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
Change History (3)
This ticket was mentioned in Slack in #core-test by ironprogrammer. View the logs.
4 years ago
#3
@
4 years ago
- Milestone Awaiting Review
- Resolution → invalid
- Status new → closed
Hi, @pnnande, welcome to WordPress Trac!
I'm sorry you're having issues with your code. Please note that Core Trac is used for enhancements and bug reports for the WordPress core software, not individual support issues or questions.
Please check out the articles referenced above by @sabernhardt, or the dedicated support forums for help with your question: https://wordpress.org/support/forums/.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Related: WordPress.org support topic and StackExchange answer