• I am trying to insert a new record into a table, and for the most part it’s working except for one string. Here’s my insert statement;

    $wpdb->insert($wpdb->uam_accessgroup_to_object, array('object_id' => $userID, 'object_type' => 'user', 'group_id' => $entry['7']), array('%s', '%d'));

    It’s creating a new record and inserting the correct values into ‘object_id’ and ‘group_id’, however ‘object_type’ which should be ‘user’ is saved in the db as ‘0’. The field type is varchar(255).

    Is there something wrong with my insert statement?

Viewing 1 replies (of 1 total)
  • Thread Starter Chris

    (@chips)

    Very strange, I moved the second field to be first in the array and it works. Code now reads;

    $wpdb->insert($wpdb->uam_accessgroup_to_object, array('object_type' => 'user', 'object_id' => $userID, 'group_id' => $entry['7']), array('%s', '%d'));

Viewing 1 replies (of 1 total)
  • The topic ‘$wpdb insert problem – not inserting string’ is closed to new replies.