我在$wpdb->insert
的自定义表格中插入行。一切都按预期工作,除非我在查询后无法获得$wpdb->insert_id
的任何ID。
这是我的函数(通过一些修改来隐藏像db表这样的真实数据):
function create_post() {
global $wpdb, $currentuser;
$wpdb->insert('my_table',array('author' => $currentuser['user_id']),array('%d'));
$id = $wpdb->insert_id;
return $id;
}
我的行完全插入,我发现$wpdb->show_errors();
和$wpdb->print_error();
没有错误。
在我的数据库中,我当然有一个AUTO_INCREMENT
id列。
关于变通办法的任何想法?