admin管理员组文章数量:1201974
How can I delete a field in my database under the posts table?
For example in my posts
table where the ID is 800 I would like to delete the a field under the column product_rank
.
Any help will be appreciated.
How can I delete a field in my database under the posts table?
For example in my posts
table where the ID is 800 I would like to delete the a field under the column product_rank
.
Any help will be appreciated.
Share Improve this question edited Jan 28, 2018 at 13:52 emily00p asked Jan 28, 2018 at 13:43 emily00pemily00p 34 bronze badges 4 |2 Answers
Reset to default 2You can't "delete" a field in MySQL, this only works for complete rows.
However, you can unset values, meaning setting them to their original state, usually NULL
or an empty string.
$wpdb->update($wpdb->posts, array(
'product_rank' => NULL
), array(
'ID' => $post_id
));
This code not working, show an error. I'm tried
Please look at this screenshot https://prnt.sc/M3DYH_EmHCtM
global $wpdb;
$id = $_REQUEST['delete'];
$table = 'custom_user_info';
$wpdb->delete( $table, array( 'id' => $id ) );
But when I'm using this code, It's working perfectly
$db_config = mysqli_connect('localhost', 'root', '', 'develop');
$id = $_REQUEST['delete'];
$delete = "DELETE FROM custom_user_info WHERE id=$id";
$query = mysqli_query($db_config, $delete);
本文标签: databaseHow to delete field using WPDB
版权声明:本文标题:database - How to delete field using WPDB? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738627005a2103522.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
product_rank
isn't a standard column in the posts table. Are you sure it's a column of the posts table and not meta? – Jacob Peattie Commented Jan 28, 2018 at 13:45$wpdb->update($wpdb->posts, array('product_rank' => $rank), array('ID' => $post_id));
– emily00p Commented Jan 28, 2018 at 13:48NULL
or similar – kero Commented Jan 28, 2018 at 13:53