demos/phonebook/protected/controllers/SiteController.php
public function saveContact($contact)
	{
		if($contact->id > 0) // update
		{
			$contact->isNewRecord=false;
			if(($oldContact=Contact::model()->findByPk($contact->id))!==null)
			{
				$oldContact->attributes=$contact->attributes;
				return $oldContact->save();
			}
			else
				return false;
		}
		else // insert
		{
			$contact->isNewRecord=true;
			$contact->id=null;
			return $contact->save();
		}
	}
public function saveContact($contact)
	{
		if($contact->id > 0) // update
		{
			$contact->isNewRecord=false;
			if(($oldContact=Contact::model()->findByPk($contact->id))!==null)
			{
				$oldContact->attributes=$contact->attributes;
				return $oldContact->save();
			}
			else
				return false;
		}
		else // insert
		{
			$contact->isNewRecord=true;
			$contact->id=null;
			return $contact->save();
		}
	}
public function saveContact ( $ contact ) { if ( $ contact -> id > 0 ) // update { $ contact -> isNewRecord = false ; if ( ( $ oldContact = Contact :: model ( ) -> findByPk ( $ contact -> id ) ) !== null ) { $ oldContact -> attributes = $ contact -> attributes ; return $ oldContact -> save ( ) ; } else return false ; } else // insert { $ contact -> isNewRecord = true ; $ contact -> id = null ; return $ contact -> save ( ) ; } }
Updates or inserts a contact.
If the ID is null, an insertion will be performed;
Otherwise it updates the existing one.
@param Contact contact model
@return boolean whether saving is successful
@soap
Updates or inserts a contact . If the ID is null an insertion will be performed ; Otherwise it updates the existing one .