wpdb::insert() & wpdb::update() need to allow typecasting of params.
|Reported by:||DD32||Owned by:||westi|
|Severity:||normal||Keywords:||dev-feedback has-patch early|
As a follow up to: http://trac.wordpress.org/ticket/6836#comment:8
insert() and update() should prepare the values before inserting/updating
I see 2 options;
- 3rd param to insert() & update() which specifies the field types; Eg: http://trac.wordpress.org/ticket/6836#comment:9
The downside to that is it'll require the type to be specified on each insert/update statement
- defining the field-types in an array to check against eg:
$wpdb->fields = array( $wpdb->posts => array('ID' => '%d', 'post_content' => '%s') ); .. in insert(): foreach( (array)$data as $key => $value ) if( isset($this->fields[ $table ][ $key ]) ) $data[$key] = sprintf($this->fields[ $table ][ $key ], $value);
The downside of this approach, Is that it'll require the list to be kept updated, However, it has the advantage of being kept updated in a single location.
If theres a preference for either method, I'm happy to roll up a patch for it.
Change History (17)
- Owner changed from anonymous to westi
- Status changed from new to assigned