public function restoreDataVersion ($strTable, $intPid, $intVersion)
	{
		$db = Database::getInstance();
		
		$objData = $db->prepare("SELECT * FROM tl_version WHERE fromTable=? AND pid=? AND version=?")
					  ->execute('tl_data', $intPid, $intVersion);

		if ($objData->numRows < 1)
		{
			return;
		}
		
		$data = \StringUtil::deserialize($objData->data);
	
		if (!is_array($data))
		{
			return;
		}
		
		// Get the currently available fields
		$arrFields = array_flip($this->Database->getFieldnames('tl_data'));

		$objStmt = $db->prepare("DELETE FROM tl_data WHERE pid=?")
					  ->execute($intPid);

		foreach ($data as $row)
		{
			// Unset fields that do not exist (see #5219)
			$row = array_intersect_key($row, $arrFields);
				
			// Reset fields added after storing the version to their default value (see #7755)
			foreach (array_diff_key($arrFields, $row) as $k=>$v)
			{
				$row[$k] = \Widget::getEmptyValueByFieldType($GLOBALS['TL_DCA']['tl_data']['fields'][$k]['sql']);
			}
			
			$db->prepare("INSERT INTO tl_data %s")
			   ->set($row)
			   ->execute($row['id']);
		}
	}
public function restoreDataVersion ($strTable, $intPid, $intVersion)
	{
		$db = Database::getInstance();
		
		$objData = $db->prepare("SELECT * FROM tl_version WHERE fromTable=? AND pid=? AND version=?")
					  ->execute('tl_data', $intPid, $intVersion);

		if ($objData->numRows < 1)
		{
			return;
		}
		
		$data = \StringUtil::deserialize($objData->data);
	
		if (!is_array($data))
		{
			return;
		}
		
		// Get the currently available fields
		$arrFields = array_flip($this->Database->getFieldnames('tl_data'));

		$objStmt = $db->prepare("DELETE FROM tl_data WHERE pid=?")
					  ->execute($intPid);

		foreach ($data as $row)
		{
			// Unset fields that do not exist (see #5219)
			$row = array_intersect_key($row, $arrFields);
				
			// Reset fields added after storing the version to their default value (see #7755)
			foreach (array_diff_key($arrFields, $row) as $k=>$v)
			{
				$row[$k] = \Widget::getEmptyValueByFieldType($GLOBALS['TL_DCA']['tl_data']['fields'][$k]['sql']);
			}
			
			$db->prepare("INSERT INTO tl_data %s")
			   ->set($row)
			   ->execute($row['id']);
		}
	}
public function restoreDataVersion ( $ strTable , $ intPid , $ intVersion ) { $ db = Database :: getInstance ( ) ; $ objData = $ db -> prepare ( "SELECT * FROM tl_version WHERE fromTable=? AND pid=? AND version=?" ) -> execute ( 'tl_data' , $ intPid , $ intVersion ) ; if ( $ objData -> numRows < 1 ) { return ; } $ data = \ StringUtil :: deserialize ( $ objData -> data ) ; if ( ! is_array ( $ data ) ) { return ; } // Get the currently available fields $ arrFields = array_flip ( $ this -> Database -> getFieldnames ( 'tl_data' ) ) ; $ objStmt = $ db -> prepare ( "DELETE FROM tl_data WHERE pid=?" ) -> execute ( $ intPid ) ; foreach ( $ data as $ row ) { // Unset fields that do not exist (see #5219) $ row = array_intersect_key ( $ row , $ arrFields ) ; // Reset fields added after storing the version to their default value (see #7755) foreach ( array_diff_key ( $ arrFields , $ row ) as $ k => $ v ) { $ row [ $ k ] = \ Widget :: getEmptyValueByFieldType ( $ GLOBALS [ 'TL_DCA' ] [ 'tl_data' ] [ 'fields' ] [ $ k ] [ 'sql' ] ) ; } $ db -> prepare ( "INSERT INTO tl_data %s" ) -> set ( $ row ) -> execute ( $ row [ 'id' ] ) ; } }
Restore tl_data versions

@param string        $strTable
@param integer       $intPid
@param integer       $intVersion
Restore tl_data versions