benjaminbeazy Posted February 6, 2008 Share Posted February 6, 2008 hey guys, trying to write a rollback function such as this... function rollback($array){ foreach($array as $var => $val){ query('DELETE FROM $var WHERE id = $val'); } } i know that syntax isn't quite right and some error checking and what not is required, but you get the idea. anyway, the problem is that the primary key isn't always named "id". in fact, rarely is it named id. is there an easy way of finding the primary key? something like this maybe... DELETE FROM $var WHERE (PRIMARY_KEY) = '$val' ??? any input will be helpful. thanks in advance! Quote Link to comment https://forums.phpfreaks.com/topic/89722-solved-find-primary-key-for-roll-back-function/ Share on other sites More sharing options...
benjaminbeazy Posted February 6, 2008 Author Share Posted February 6, 2008 oh yeah, the db type is MyISAM. can't change it to allow transactions. Quote Link to comment https://forums.phpfreaks.com/topic/89722-solved-find-primary-key-for-roll-back-function/#findComment-459761 Share on other sites More sharing options...
trq Posted February 6, 2008 Share Posted February 6, 2008 Theres probably no easy way of doing it but you could make a function to find it using mysql_get_fields and mysql_field_type. Quote Link to comment https://forums.phpfreaks.com/topic/89722-solved-find-primary-key-for-roll-back-function/#findComment-459838 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.