WordPress.org

Ready to get started?Download WordPress

Forums

wpdb-insert Duplicate (1 post)

  1. aiwarrior
    Member
    Posted 5 years ago #

    Hi
    Recently i have been developing some code. Heres what i have been trying to do:

    1-> I create a table just like advised in the codex
    2-> I have a function that check for some data and tries to set it in the created tables using the wpdb-insert function.

    My DB has this structure:
    $sql = "CREATE TABLE " . $table_name . " (

    post_name VARCHAR(15) NOT NULL,

    url VARCHAR(55) NOT NULL

    UNIQUE KEY id (id));";

    The problem is that wpdb-insert is making duplicate entries each time the function runs. From what i have read i thought that insert default behaviour was to return an error if the entry already existed. I wanted to refrain from making a query to check if that entry already existed but i was unable to find a solution. Do you have any suggestion?

    Thanks

Topic Closed

This topic has been closed to new replies.

About this Topic