[wp-trac] [WordPress Trac] #31042: WPDB field_types Variable Too Broad?

WordPress Trac noreply at wordpress.org
Sat Jan 17 04:53:36 UTC 2015


#31042: WPDB field_types Variable Too Broad?
-------------------------+------------------------------
 Reporter:  njkrut       |       Owner:
     Type:  enhancement  |      Status:  new
 Priority:  normal       |   Milestone:  Awaiting Review
Component:  Database     |     Version:
 Severity:  normal       |  Resolution:
 Keywords:               |     Focuses:
-------------------------+------------------------------

Comment (by njkrut):

 Replying to [comment:1 nacin]:
 > In general, `$field_types only` benefits WordPress core, as you'd
 generally want to specify formats for values (for INSERT, UPDATE) and
 where values (for UPDATE, DELETE). So, while core may do:
 >
 > {{{
 > $wpdb->update( $wpdb->users, array( 'user_activation_key' => $key, 'ID'
 => $id ) )
 > }}}
 >
 > A plugin should always do:
 > {{{
 > $wpdb->update( 'custom_table', array( 'user_activation_key' => $key,
 'ID' => $id ), array( '%s', '%d' ) )
 > }}}
 >
 > I do see the benefit of allowing it so a plugin can register their field
 types with WordPress, but as it stands right now, that's not how it's
 designed... It's mostly just an internal thing, designed only for core
 columns.

 I don't see why plugins should be required to force a format to every
 column on inserts and updates. I have built a custom REST addon for
 WordPress so my insert and update queries aren't always as simple as your
 examples. My problem is not the benefit of the `$field_types` but the
 issue when you have overlapping fields on a `$wpdb->insert` call... Such
 as `user_id`

--
Ticket URL: <https://core.trac.wordpress.org/ticket/31042#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list