Jump to content

Whats an equivalent to mysql_num_rows, oci_num_rows doesn't do the same.


mboley370

Recommended Posts

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.";
}

}

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.