Forums

[resolved] First insert to new table isn't working (2 posts)

  1. amitstreak
    Member
    Posted 11 months ago #

    Hi,

    I created a new mySql table and I need the first field to be an index and a key.
    I'm not sure I got the terminology right but I simply need that field to automatically increment by 1 with each insert.
    So I defined that field as an index and gave it the auto_increment attribute.
    Now I try to insert the first row like this:

    $wpdb->insert('wp_branches', array(user_id=>$user_id, branchName=>$bname));

    The index/key field branchId is missing from this query because I'm counting on the db to automatically give it the value 1 since it's the first insert, and then increment it with every additional insert.
    For some reason the row isn't being inserted and db is left empty.
    What am I doing wrong?

  2. amitstreak
    Member
    Posted 11 months ago #

    Found the problem. Wrong field name. user_id should be userId.

Reply

You must log in to post.

About this Topic