Private/Polyfony/Record/Aware.php
public function save() :bool {
		
		// if an id already exists
		if($this->_['id']) {
			// we can update and return the number of affected rows (0 on error, 1 on success)
			return (bool) self::_update()
				->set($this->__toArray(true, true))
				->where(['id'=>$this->_['id']])
				->execute();
		}
		// this is a new record
		else {
			// try to insert it
			$inserted_object = self::create($this->__toArray(true, true));
			// if insertion succeeded, return true
			if($inserted_object) {
				// clone ourselves with what the database returneds, a full fledged object
				$this->replicate($inserted_object);
				// return success
				return true;
			}
			// didnt insert
			else {
				// failure feedback
				return false;
			}
		}
		
	}
public function save() :bool {
		
		// if an id already exists
		if($this->_['id']) {
			// we can update and return the number of affected rows (0 on error, 1 on success)
			return (bool) self::_update()
				->set($this->__toArray(true, true))
				->where(['id'=>$this->_['id']])
				->execute();
		}
		// this is a new record
		else {
			// try to insert it
			$inserted_object = self::create($this->__toArray(true, true));
			// if insertion succeeded, return true
			if($inserted_object) {
				// clone ourselves with what the database returneds, a full fledged object
				$this->replicate($inserted_object);
				// return success
				return true;
			}
			// didnt insert
			else {
				// failure feedback
				return false;
			}
		}
		
	}
public function save ( ) : bool { // if an id already exists if ( $ this -> _ [ 'id' ] ) { // we can update and return the number of affected rows (0 on error, 1 on success) return ( bool ) self :: _update ( ) -> set ( $ this -> __toArray ( true , true ) ) -> where ( [ 'id' => $ this -> _ [ 'id' ] ] ) -> execute ( ) ; } // this is a new record else { // try to insert it $ inserted_object = self :: create ( $ this -> __toArray ( true , true ) ) ; // if insertion succeeded, return true if ( $ inserted_object ) { // clone ourselves with what the database returneds, a full fledged object $ this -> replicate ( $ inserted_object ) ; // return success return true ; } // didnt insert else { // failure feedback return false ; } } }
update or create
update or create