M.O.S. Studios Posted May 5, 2009 Share Posted May 5, 2009 Hey, I'm writting a script that deletes multiple rows from a mysql db. this is how I'm doing it at the moment $db_headers=mysql_query("SELECT * FROM `headers` WHERE `header` = '".$_POST['head_index']."'"); while(list($index, $name, $internal, $inlink, $exlink, $header, $sort, $act)=mysql_fetch_array($db_headers)) { $query="DELETE FROM `headers` WHERE `headers` = ".index." LIMIT 1"; mysql_query($query); $resaults .=$name." hass been deleted."; } i know i could do this mysql_query("DELETE FROM `headers` WHERE `header` = '".$_POST['head_index']."'"); how ever how would i get the Fields it deleted? Quote Link to comment https://forums.phpfreaks.com/topic/156942-viewing-names-of-deleted-mysql-rows/ Share on other sites More sharing options...
Maq Posted May 5, 2009 Share Posted May 5, 2009 how ever how would i get the Fields it deleted? SELECT them first. Quote Link to comment https://forums.phpfreaks.com/topic/156942-viewing-names-of-deleted-mysql-rows/#findComment-826663 Share on other sites More sharing options...
M.O.S. Studios Posted May 5, 2009 Author Share Posted May 5, 2009 well in the top example that's what i did, how ever i was wondering if there was a function that would mark down a value be deleting it. that way i don't have to scan the db twice, if not i can continue doing it the way i originally had it. Quote Link to comment https://forums.phpfreaks.com/topic/156942-viewing-names-of-deleted-mysql-rows/#findComment-826669 Share on other sites More sharing options...
fenway Posted May 5, 2009 Share Posted May 5, 2009 how ever i was wondering if there was a function that would mark down a value be deleting it. that way i don't have to scan the db twice, if not i can continue doing it the way i originally had it. Huh? Quote Link to comment https://forums.phpfreaks.com/topic/156942-viewing-names-of-deleted-mysql-rows/#findComment-826748 Share on other sites More sharing options...
PFMaBiSmAd Posted May 5, 2009 Share Posted May 5, 2009 In most real life applications data is not actually deleted. It if was worth the time to insert it into a table it is valuable enough to keep for some future purpose (restore, reporting, tracking...) It is just marked as being deleted or it is moved to a deleted item table. Quote Link to comment https://forums.phpfreaks.com/topic/156942-viewing-names-of-deleted-mysql-rows/#findComment-826756 Share on other sites More sharing options...
M.O.S. Studios Posted May 5, 2009 Author Share Posted May 5, 2009 i thought i would reword my last statment: well in the top example I do select all the values before deleting them, so i can have a list of what was deleted. however I was wondering if there was a function that would select and mark down a value before deleting it. That way i dont have to do 2 db querys. And i do need to delete them, there is no reason i would need to resotre them. Quote Link to comment https://forums.phpfreaks.com/topic/156942-viewing-names-of-deleted-mysql-rows/#findComment-826777 Share on other sites More sharing options...
fenway Posted May 5, 2009 Share Posted May 5, 2009 You're asking if DELETE will also SELECT? No, it won't. if you want both, you have to do both. Quote Link to comment https://forums.phpfreaks.com/topic/156942-viewing-names-of-deleted-mysql-rows/#findComment-826826 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.