[TYPO3-dev] DBAL mapping columns back to result set

Jigal van Hemert jigal at xs4all.nl
Thu Jun 23 11:25:21 CEST 2011


Hi,

I have a small problem with queries I send through DBAL to an extra 
MySQL database.

[...]
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['dbal']['table2handlerKeys'] = array(
	'fc_projects' => 'projectFilesdb',
	'fc_cr_user_project' => 'projectFilesdb',
	'fc_users' => 'projectFilesdb',
);

$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['dbal']['mapping'] = array(
	'tx_projectfiles_user' => array(
		'mapTableName' => 'fc_users',
		'mapFieldNames' => array(
			'uid' => 'userid',
			'username' => 'loginname',
			'nickname' => 'nickname',
		),
	),
	'tx_projectfiles_projects_user' => array(
		'mapTableName' => 'fc_cr_user_project',
		'mapFieldNames' => array(
			'uid_local' => 'userid',
			'uid_foreign' => 'projectid',
		),
	),
	'tx_projectfiles_projects' => array(
		'mapTableName' => 'fc_projects',
		'mapFieldNames' => array(
			'uid' => 'projectid',
			'title' => 'projectname',
			'number' => 'projectnr',
			'hidden' => 'is_locked',
			'owner' => 'ownerid',
		),
	),
);

This works fine when executing queries.

$projectData = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
  'tx_projectfiles_projects.number, tx_projectfiles_projects.title, 
tx_projectfiles_projects.owner, tx_projectfiles_user.uid',

  'tx_projectfiles_projects INNER JOIN tx_projectfiles_projects_user ' .
  'ON 
tx_projectfiles_projects_user.uid_foreign=tx_projectfiles_projects.uid ' .
  'INNER JOIN tx_projectfiles_user ' .
  'ON tx_projectfiles_user.uid=tx_projectfiles_projects_user.uid_local',

  'tx_projectfiles_user.username=' .
    $GLOBALS['TYPO3_DB']->fullQuoteStr(
      $loggedInUser,
      'tx_projectfiles_projects'
    )
);

It returns the right records, but each record array has the keys:
number
title
owner
userid

The last one should be 'uid' because of the mapping for the 
tx_projectfiles_user table. 'userid' is the column name on the databse 
side, not on the TYPO3 side.

It almost seems that only the first table columns get mapped back to the 
TYPO3 names.
I'd like to verify this and provide a fix, but I couldn't find where 
this mapping is performed. Any hints?

-- 
Kind regards / met vriendelijke groet,

Jigal van Hemert.




More information about the TYPO3-dev mailing list