mboley370 Posted June 22, 2010 Share Posted June 22, 2010 So i have checked all over google and I can' find anything that works the same as mysql_num_rows. I tried oci_num_rows but it just doesn't work the same. The code below worked in mysql, it works and updates now in oracle, however. The part below where it compares how many rows are being used won't work anymore. It just shows up as updated every time. I am only looking for the rows that have changed. If my staff member doesn't update anything I have it show up and say. " You profile hasn't changed nothing was updated" if ($rowsAffected == 0) This is the part here that I can't get to work properly which is down below as you can see. Do i need to use some kind of count. Could someone give an example please. f($error==0){ $updateQuery = "UPDATE staffMember SET smFirstName = '$smFirstName', smLastName = '$smLastName', smPhone = '$smPhone', smAddress = '$smAddress', smCity = '$smCity', smState = '$smState', smZip = '$smZip', smEmail = '$smEmail', smExperience = '$smExperience', smEducation = '$smEducation', smSchool = '$smSchool', smCertification = '$smCertification', smAvailability = '$smAvailability', smStatus = '$smStatus', smTravel = '$smTravel', smSalary = '$smSalary', smEmployer = '$smEmployer', smPositionType = '$smPositionType', smYearsWorked = '$smYearsWorked', smSkills = '$smSkills', smHobbies = '$smHobbies', smProfileImage = '$smProfile_Image', smUploadResume = '$smUpload_Resume', smPassword = '$smPassword' WHERE staffMemberId = '{$staffID}'"; //$result = mysql_query($updateQuery); //confirm_query($result); $result = oci_parse($conn, "$updateQuery"); oci_execute($result); $rowsAffected = oci_num_rows($result); if ($rowsAffected == 0) { redirect_to("staffArea.php?update=2"); } else if ($rowsAffected != -1) { redirect_to("staffArea.php?update=1"); } else { $message .= "Error occurred while updating database. Please try again."; } } Quote Link to comment https://forums.phpfreaks.com/topic/205555-whats-an-equivalent-to-mysql_num_rows-oci_num_rows-doesnt-do-the-same/ Share on other sites More sharing options...
PFMaBiSmAd Posted June 22, 2010 Share Posted June 22, 2010 In mysql, if you execute an UPDATE query and none of the values are actually different, the actual UPDATE is not performed and the table is not changed. There is no guarantee that any other database exhibits that same behavior. You would need to check the values yourself in your code to determine if the submitted values are the same as the existing values. Quote Link to comment https://forums.phpfreaks.com/topic/205555-whats-an-equivalent-to-mysql_num_rows-oci_num_rows-doesnt-do-the-same/#findComment-1075590 Share on other sites More sharing options...
mboley370 Posted June 22, 2010 Author Share Posted June 22, 2010 In mysql, if you execute an UPDATE query and none of the values are actually different, the actual UPDATE is not performed and the table is not changed. There is no guarantee that any other database exhibits that same behavior. You would need to check the values yourself in your code to determine if the submitted values are the same as the existing values. I understand now. I didn't know that. I did however see that no matter what it updated the table every time with the same data that is why i was getting a lot of rows returned even if it was the same data. Thanks you saved me a lot of time trying to figure this out. Matt Quote Link to comment https://forums.phpfreaks.com/topic/205555-whats-an-equivalent-to-mysql_num_rows-oci_num_rows-doesnt-do-the-same/#findComment-1075612 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.