[wp-trac] [WordPress Trac] #43578: Unexpected MYSQL data format

WordPress Trac noreply at wordpress.org
Mon Mar 19 19:36:02 UTC 2018


#43578: Unexpected MYSQL data format
--------------------------+-----------------------------
 Reporter:  loranrendel   |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Database      |    Version:  4.9.4
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 When I use field `user_id` in `$wpdb->insert` it set value to Integer, but
 the table I add data into has `user_id` text field.
 It works normally only if `format` parameter specified.

 Example:
 {{{#!php
 <?php
 $wpdb->query("CREATE TABLE {$wpdb->prefix}_test (`id` INT, `user_id`
 VARCHAR(16))");
 $wpdb->insert("{$wpdb->prefix}_test", ['id' => 1, 'user_id' =>
 'stringKey']);
 print_r($wpdb->get_row("SELECT * FROM {$wpdb->prefix}_test WHERE id =
 1"));
 }}}

 Result: `stdClass Object ( [id] => 1 [user_id] => 0 )`

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


More information about the wp-trac mailing list