WordPress.org

Ready to get started?Download WordPress

Forums

null and boolean values with $wpdb->insert (3 posts)

  1. jacquesc
    Member
    Posted 4 years ago #

    When I try to insert null or true into a database using $wpdb->insert, it puts quotes around the values and MySQL chokes.

    $data_array = array(JB_SOURCE_TITLE => $this->feed->get_title(),
                        JB_SOURCE_DATERECEIVED        => 'NULL');
    $wpdb->insert( $wpdb->prefix . JB_SOURCETABLE, $data_array)

    gives

    WordPress database error: [Incorrect datetime value: 'NULL' for column 'dateReceived' at row 1]
    INSERT INTO <code>wp_jobboard_sources</code> (<code>title</code>,<code>dateReceived</code>) VALUES ('the feed','NULL')

    Is there any workaround for this other than constructing the query from scratch?

  2. jacquesc
    Member
    Posted 4 years ago #

    err mysql error output produces backticks ... the output actually looked like:

    WordPress database error: [Incorrect datetime value: 'NULL' for column 'dateReceived' at row 1]
    INSERT INTO *wp_jobboard_sources* (*title*, *dateReceived*) VALUES ('the feed','NULL')

    where * is actually a backtick.

  3. mattyway
    Member
    Posted 4 years ago #

    Did you find a solution to this jacquesc? I am trying to use $wpdb->update to set variables to null.

Topic Closed

This topic has been closed to new replies.

About this Topic