public function Replace($Table = '', $Set = NULL, $Where, $CheckExisting = FALSE) {
      if(count($this->_Sets) > 0) {
         foreach($this->_Sets as $Key => $Value) {
            if(array_key_exists($Value, $this->_NamedParameters)) {
               $Set[$Key] = $this->_NamedParameters[$Value];
               unset($this->_NamedParameters[$Value]);
            } else {
               $Set[$Key] = $Value;
            }
         }
         $this->_Sets = array();
      }
      
      // Check to see if there is a row in the table like this.
      if ($CheckExisting) {
         $Row = $this->GetWhere($Table, $Where)->FirstRow(DATASET_TYPE_ARRAY);

         $Update = FALSE;
         if ($Row) {
            $Update = TRUE;
            foreach ($Set as $Key => $Value) {
               unset($Set[$Key]);
               $Key = trim($Key, '`');
               
               if (!$this->CaptureModifications && !array_key_exists($Key,$Row))
                  continue;

               if (in_array($Key, array('DateInserted', 'InsertUserID', 'DateUpdated', 'UpdateUserID')))
                  continue;


               // We are assuming here that if the existing record doesn't contain the column then it's just been added.
               if (preg_match('/^`(.+)`$/', $Value, $Matches)) {
                  if (!array_key_exists($Key, $Row) || $Row[$Key] != $Row[$Matches[1]])
                     $this->Set('`'.$Key.'`', $Value, FALSE);
               } elseif (!array_key_exists($Key, $Row) || $Row[$Key] != $Value) {
                  $this->Set('`'.$Key.'`', $Value);
               }
               
            }
            if (count($this->_Sets) == 0) {
               $this->Reset();
               return;
            }
         }
      } else {
         $Count = $this->GetCount($Table, $Where);
         $Update = $Count > 0;
      }

      if($Update) {
         // Update the table.
         $this->Put($Table, $Set, $Where);
      } else {
         // Insert the table.
         $Set = array_merge($Set, $Where);
         $this->Insert($Table, $Set);
      }
   }