aniesh82 Posted August 18, 2008 Share Posted August 18, 2008 Hi, I have an UPDATE query and after executes it, I need to find out the ids of the records where the actual updation occurs.. I can find out the 'total updation' using the mysql_affected_rows() function.. But is there any php function or class available for this specific purpose? thank you, php developer, Cochin-India. Link to comment https://forums.phpfreaks.com/topic/120279-update-query-mysql_affected_rows/ Share on other sites More sharing options...
pocobueno1388 Posted August 18, 2008 Share Posted August 18, 2008 Before you do the update, just do a select query that has the same WHERE clause as the update query. Link to comment https://forums.phpfreaks.com/topic/120279-update-query-mysql_affected_rows/#findComment-619660 Share on other sites More sharing options...
MatthewJ Posted August 19, 2008 Share Posted August 19, 2008 Just a thought as I am sure there is a better way, but when you're doing the update I would assume the update SQL specifies which row to update or it would not update the proper item... If so, you must b e passwing the id as part of the WHERE clause. Could you loop through the items you are updating and add that id to an array after each query is executed? For instance: $ids = array(1, 3, 5, 7, 9); foreach($ids as $v) { $SQL = "UPDATE table SET field = 'value' WHERE recordid = $v"; $res = mysql_query($SQL, $conn); if($res) { $updated[] = $v } } Obviously the first array is just for examples sake Just a thought Link to comment https://forums.phpfreaks.com/topic/120279-update-query-mysql_affected_rows/#findComment-619662 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.