• 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?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter jacquesc

    (@jacquesc)

    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.

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

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘null and boolean values with $wpdb->insert’ is closed to new replies.