在Wordpress中捕获重复键错误

时间:2016-05-09 07:03:07

标签: wordpress duplicates key

我有这个代码,我想在其中添加重复错误捕获,我该怎么办?

if (!$row_id) {
    // insert a new
    if ($wpdb->insert($table_name, $args)) {
        return $wpdb->insert_id;
    }
} else {
    // do update method here
    if ($wpdb->update($table_name, $args, array('id' => $row_id))) {
        return $row_id;
    }
}

0 个答案:

没有答案