[TYPO3-mvc] Mapping Error?
Philipp
philippwrann at gmx.at
Mon Feb 25 13:50:04 CET 2013
I KNOW - much to read here :) but i think i have just some bad config, so please take a little look :)
I think i have a mapping error in my TCA or something. My scenario:
I have a aggregate model called RegionalObject. One property is called regionalObjects, as you might guess this should be a MM relaton to other objects.
The configuration in the TCA works so far one-way, so if i set one record B as relation to record A it is correctly set, but if i open record B the relation is not visible. I thought - no problem, i fix this in my repository using a logicalOr statement.
That looks like this:
##########
$query = $this->createQuery();
$logicalAnd = array(
$query->in('type',$types),
$query->logicalOr(
$query->equals('regionalObjects.uidLocal',$regionalObject->getUid()),
$query->equals('regionalObjects.uidForeign',$regionalObject->getUid())
),
$query->logicalNot($query->equals('uid',$regionalObject->getUid()))
);
if ($excludeAllreadyDisplayed) {
array_push(
$logicalAnd,
$query->logicalNot(
$query->in('uid',\Pixelpoint\RegionalObject\Register\RegionalObjectRegister::getLibrary())
)
);
}
return $query->matching($query->logicalAnd($logicalAnd))->setLimit($limit)->execute();
##########
But here i get the mysql error, its about the 2 left joins.
Not unique table/alias: 'tx_regionalobject_domain_model_regionalobject'
The rendered SQL Statement looks like this:
SELECT DISTINCT tx_regionalobject_domain_model_regionalobject.*
FROM tx_regionalobject_domain_model_regionalobject
LEFT JOIN tx_regionalobject_robject_robject_mm ON tx_regionalobject_domain_model_regionalobject.uid=tx_regionalobject_robject_robject_mm.uid_foreign
LEFT JOIN tx_regionalobject_domain_model_regionalobject ON tx_regionalobject_robject_robject_mm.uid_local=tx_regionalobject_domain_model_regionalobject.uid
WHERE (
(
(
tx_regionalobject_domain_model_regionalobject.type IN ('event')
AND (
tx_regionalobject_domain_model_regionalobject.uid_local = '694'
OR tx_regionalobject_domain_model_regionalobject.uid_foreign = '694'
)
)
AND NOT (
tx_regionalobject_domain_model_regionalobject.uid = '694'
)
)
AND NOT (
tx_regionalobject_domain_model_regionalobject.uid IN ('694')
)
)
AND tx_regionalobject_domain_model_regionalobject.deleted=0
AND tx_regionalobject_domain_model_regionalobject.t3ver_state<=0
AND tx_regionalobject_domain_model_regionalobject.pid<>-1
AND tx_regionalobject_domain_model_regionalobject.hidden=0
AND tx_regionalobject_domain_model_regionalobject.starttime<=1361794620
AND (
tx_regionalobject_domain_model_regionalobject.endtime=0
OR tx_regionalobject_domain_model_regionalobject.endtime>1361794620
)
AND (
tx_regionalobject_domain_model_regionalobject.sys_language_uid IN (0,-1)
) LIMIT 6;
##########
My tablestructure of the MM Table:
CREATE TABLE tx_regionalobject_robject_robject_mm (
uid int(11) DEFAULT '0' NOT NULL auto_increment,
pid int(11) DEFAULT '0' NOT NULL,
uid_local int(11) unsigned DEFAULT '0' NOT NULL,
uid_foreign int(11) unsigned DEFAULT '0' NOT NULL,
sorting int(11) unsigned DEFAULT '0' NOT NULL,
sorting_foreign int(11) unsigned DEFAULT '0' NOT NULL,
tablenames varchar(255) DEFAULT '' NOT NULL,
fieldname tinytext,
PRIMARY KEY (uid),
KEY parent (pid),
KEY uid_local (uid_local),
KEY uid_foreign (uid_foreign)
);
##########
Should be possible to store link it to other records as well...
My TCA:
'type' => 'select',
'size' => 10,
'maxitems' => 100,
'autoSizeMax' => 30,
'multiple' => 0,
'foreign_table' => 'tx_regionalobject_domain_model_regionalobject',
'foreign_table_where' => 'AND ###THIS_UID### != tx_regionalobject_domain_model_regionalobject.uid',
'MM' => 'tx_regionalobject_robject_robject_mm',
'MM_opposite_field' => 'regional_objects',
'selectedListStyle' => 'width:150px;',
'itemListStyle' => 'width:150px;',
'multiple' => false,
'wizards' => array(
'suggest' => array(
'type' => 'suggest'
)
)
##########
thanks for reading
kind regards Philipp
More information about the TYPO3-project-typo3v4mvc
mailing list