Jump to content

updating a database


spires

Recommended Posts

Hi

 

I am trying my first OOP update.

I have it working exactly as I want except for one thing.

 

For some reason if I try to update the database with the same information (every column exactly the same)

it returns 0 affected rows.

 

is there anyway of getting the database to update, even if all columns are exactly the same?

 

 

Code:

		$membershipID = Profile_membership::find_membership_ID($UID);
		$MID = $membershipID->id;
		$new_member = Profile_membership::make($MID, $UID, $acc_type, $membership, $upgradeL, $date, $dateUpgraded);
		if($new_member && $new_member->save()){
			$flag = 1;
		}else{
			$message .= "Error: Sorry, there was an error creating your membership. <br> Please try again<br>";	
			$flag = 0;
		}

 

 

$new_member->save() will create the database entry if no ID exists, and will update if an ID does exist.

 

So, I want the save() to return success. If it does, move on else give an error.

 

However, I'm getting the error, if a user accidentally clicks submit, when no fields have been changed.

I what it to still update, so $flag will be 1

 

 

Thanks :)

Link to comment
https://forums.phpfreaks.com/topic/216901-updating-a-database/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.