[wp-trac] [WordPress Trac] #15158: wpdb insert & update with null values
WordPress Trac
noreply at wordpress.org
Tue Mar 4 20:58:16 UTC 2014
#15158: wpdb insert & update with null values
-------------------------+-----------------------------
Reporter: westi | Owner: sorich87
Type: enhancement | Status: reopened
Priority: normal | Milestone: Future Release
Component: Database | Version: 3.0.1
Severity: normal | Resolution:
Keywords: needs-patch | Focuses:
-------------------------+-----------------------------
Comment (by son9ne):
If it helps anyone, this is how I am able to get NULL values using the
insert method.
{{{
$result = $wpdb->insert(
$wpdb->prefix . Database::USER_LOG_TABLE,
array(
'user_id' => get_current_user_id(),
'post_id' => $postID,
'user_action' => $action,
'user_action_from' => $from,
'user_action_to' => $to,
),
array(
'%d',
'%d',
'%s',
is_null($from) ? 'NULL' : '%s',
is_null($to) ? 'NULL' : '%s'
)
);
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/15158#comment:40>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list