<commit_before>RFC 0044: New save() method in DataSet
========================================================================
$Id$

@authors: friebe
@created: Tue Dec  6 16:53:23     2005
@status: draft
@category: rdbms

Scope of Change
---------------
The rdbms.DataSet class will be added a save() method.


Rationale
---------
Replace the "insert for new objects and update for existing ones"-
boilerplate code piece.


Functionality
-------------

Current example:
~~~~~~~~~~~~~~~~
<?php
  $new= FALSE;
  if (!($ds= &DataSetSubClass::getByPk($id))) {
    $ds= &new DataSetSubClass();
    $new= TRUE;
  }
  
  $ds->setName($name);
  
  // Begin boilerplate
  if ($new) {
    $ds->insert();
  } else {
    $ds->update();
  }
?>

New example:
~~~~~~~~~~~~
<?php
  $new= FALSE;
  if (!($ds= &DataSetSubClass::getByPk($id))) {
    $ds= &new DataSetSubClass();
    $new= TRUE;
  }
  
  $ds->setName($name);
  
  // Begin new code
  $ds->save();
?>


Security considerations
-----------------------
n/a


Speed impact
------------
Two new methods and one new member in rdbms.DataSet -> almost none.


Dependencies
------------
n/a


Related documents
-----------------
- http://xp-framework.net/downloads/0044.rfc.diff
  Patch implementing this RFC

<commit_msg>- Remove unused variable from new example<commit_after>RFC 0044: New save() method in DataSet
========================================================================
$Id$

@authors: friebe
@created: Tue Dec  6 16:53:23     2005
@status: draft
@category: rdbms

Scope of Change
---------------
The rdbms.DataSet class will be added a save() method.


Rationale
---------
Replace the "insert for new objects and update for existing ones"-
boilerplate code piece.


Functionality
-------------

Current example:
~~~~~~~~~~~~~~~~
<?php
  $new= FALSE;
  if (!($ds= &DataSetSubClass::getByPk($id))) {
    $ds= &new DataSetSubClass();
    $new= TRUE;
  }
  
  $ds->setName($name);
  
  // Begin boilerplate
  if ($new) {
    $ds->insert();
  } else {
    $ds->update();
  }
?>

New example:
~~~~~~~~~~~~
<?php
  if (!($ds= &DataSetSubClass::getByPk($id))) {
    $ds= &new DataSetSubClass();
  }
  
  $ds->setName($name);
  
  // Begin new code
  $ds->save();
?>


Security considerations
-----------------------
n/a


Speed impact
------------
Two new methods and one new member in rdbms.DataSet -> almost none.


Dependencies
------------
n/a


Related documents
-----------------
- http://xp-framework.net/downloads/0044.rfc.diff
  Patch implementing this RFC


{'fraction_non_alphanumeric': 0.27612236789829164, 'fraction_numerical': 0.015097338100913786, 'mean_word_length': 2.5868945868945867, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '61567', 'n_tokens_mistral': 847, 'n_tokens_neox': 786, 'n_words': 226}