/**
  * Copies all records from tables in $copyTablesArray from page with $old_pid to page with $new_pid
  * Uses raw-copy for the operation (meant for versioning!)
  *
  * @param integer $oldPageId Current page id.
  * @param integer $newPageId New page id
  * @param array $copyTablesArray Array of tables from which to copy
  * @param t3lib_TCEmain $tcemainObj TCEmain object
  * @return void
  * @see versionizePages()
  */
 protected function rawCopyPageContent($oldPageId, $newPageId, array $copyTablesArray, t3lib_TCEmain $tcemainObj)
 {
     global $TCA;
     if ($newPageId) {
         foreach ($copyTablesArray as $table) {
             // all records under the page is copied.
             if ($table && is_array($TCA[$table]) && $table != 'pages') {
                 $mres = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid', $table, 'pid=' . intval($oldPageId) . $tcemainObj->deleteClause($table));
                 while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($mres)) {
                     // Check, if this record has already been copied by a parent record as relation:
                     if (!$tcemainObj->copyMappingArray[$table][$row['uid']]) {
                         // Copying each of the underlying records (method RAW)
                         $tcemainObj->copyRecord_raw($table, $row['uid'], $newPageId);
                     }
                 }
                 $GLOBALS['TYPO3_DB']->sql_free_result($mres);
             }
         }
     }
 }