使用array_diff删除mysql记录 [英] Delete mysql records with array_diff
本文介绍了使用array_diff删除mysql记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试整理一个页面,根据项目是否未被删除,从数据库中删除记录,我已经有了现有项目一个数组(让我们为了参数而称之为array1):
展开 | 选择 | Wrap | 行号
解决方案
阅读手册。
array_diff()返回一个数组,其中包含array2中不存在于array2中的所有值。
你确定你的意思是DELETE FROM`database`?
阅读手册。
array_diff()返回一个数组,其中包含array2中不存在的array1的所有值。
And你确定你的意思是删除`数据库`吗?
Nah,我的意思是''表'',但你明白了。
array_diff的用法是我认为,如果我print_r它得到:
展开 | 选择 | Wrap | 行号
我正在尝试整理一个页面,根据项目是否未被删除从数据库中删除记录,我已经有了现有的项目在一个数组中(让我们为了争论而称之为array1):
然后我尝试和合作使用array_diff对数组进行操作,并通过执行以下操作从数据库中删除其余数组:
[PHP]
foreach(array_diff(
Hi,
I''m trying to put together a page that deletes records from a database based on if an item is unticked, I''ve got the existing items in an array (let''s call it array1 for the sake of argument):
Expand|Select|Wrap|Line Numbers解决方案Read the manual.
array_diff() returns an array containing all the values of array1 that are NOT present in array2.
And are you sure you mean DELETE FROM `database`?
Read the manual.
array_diff() returns an array containing all the values of array1 that are NOT present in array2.
And are you sure you mean DELETE FROM `database`?Nah, I meant ''table'', but you get the idea :)
The usage of array_diff is right I think, if I print_r it I get:
Expand|Select|Wrap|Line Numbers
Hi,
I''m trying to put together a page that deletes records from a database based on if an item is unticked, I''ve got the existing items in an array (let''s call it array1 for the sake of argument):
I then try and compare the arrays using array_diff and delete the remaining arrays from the database by doing the following:
[PHP]
foreach (array_diff(
这篇关于使用array_diff删除mysql记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文登录 关闭
扫码关注1秒登录发送“验证码”获取 | 15天全站免登陆