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