/** Set the query field to a SQL string that saves the specified object field values in the database.
	* @param anObject Object whose field values need to be saved
	* @tableName String
	* @param fieldMap Associative Array mapping fieldName to columnName
	* @param insert wheather a record for the object should be inserted. If false the objects record will be updated
	*/
	function setQueryToSaveObject_table_fieldMap($anObject, $tableName, $fieldMap, $insert) {
		if ($insert) return $this->setQueryToInsertObject_table_fieldMap($anObject, $tableName, $fieldMap);

		$sql  = "update $tableName SET ";

		$sep = "";
		reset($fieldMap);
		forEach($fieldMap as $field => $column) {
			//insert of a not-new object is assumed to be insert in secondary table
			if ($field != 'id' ) {
				$sql .= $sep;
				$sql .= $column;
				$sql .= '=';
				$sql .= $this->param(isSet($anObject->$field) ? $anObject->$field : null);
				$sep = ', ';
			}
		}
		$this->query = $sql;
		$this->where_equals(
			$fieldMap['id'] // the column name for field 'id'
			, $anObject->id
		);
	}