WordPress.org

Ready to get started?Download WordPress

Forums

simple syntax question: wpdb->prepare() (2 posts)

  1. lavishcreative
    Member
    Posted 5 years ago #

    I have a whole load of values (strings and integers mixed) that I need to insert into separate columns in my database. This is what I have so far:

    $keys = "column1, column2, column3, column4,... and so on";
    $values = "value1, value2, value3, value4... and so on";
    
    $wpdb->query($wpdb->prepare("INSERT INTO tablename ($keys) VALUES ($values))";

    Is this possible, or do I have to create a separate variable for each value and declare each as a '%d' or a '%s' ??

  2. lavishcreative
    Member
    Posted 5 years ago #

    I take it this is not a simple question??

Topic Closed

This topic has been closed to new replies.

About this Topic