[TYPO3-german] Re: Nativer SQL mit zwei Tabellen
David Brünner
david.bruenner at t-online.de
Tue Jan 16 14:25:48 CET 2018
Ich habs hinbekommen. TCA hat gefehlt - dachte das wird nur für die BE-Views benötigt.
Also mal alles zusammen:
[code]
CREATE view tx_kkbaybw_domain_model_fesearch AS
SELECT (uid + 100000) AS uid, bezeichnung AS name, '' AS vorname, '' AS nachname, '' AS gebaeude
FROM tx_kkbaybw_domain_model_gebaeude
UNION ALL
SELECT (uid + 200000) AS uid, concat(vorname, ' ', nachname) AS name, vorname, nachname, gebaeude_id AS gebaeude
FROM tx_kkbaybw_domain_model_ansprechpartner
[/code]
Model
[code]
<?php
namespace KKSoftware\Kkbaybw\Domain\Model;
class FeSearch extends BaseModel {
/**
* @var string
*/
protected $name;
/**
* @var string
*/
protected $vorname;
/**
* @var string
*/
protected $nachname;
/**
* @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\KKSoftware\Kkbaybw\Domain\Model\Gebaeude>
*/
protected $gebaeude;
/**
* @return string
*/
public function getName() {
return $this->name;
}
/**
* @return string
*/
public function getVorname() {
return $this->vorname;
}
/**
* @return string
*/
public function getNachname() {
return $this->nachname;
}
/**
* @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\KKSoftware\Kkbaybw\Domain\Model\Gebaeude>
*/
public function getGebaeude() {
return $this->gebaeude;
}
}
[/code]
Repository ist lediglich eine leere Klasse.
TCA
[code]
<?php
return [
'columns' => [
'name' => [
'exclude' => false,
'label' => 'name',
'config' => [
'type' => 'input',
'size' => 30,
'eval' => 'trim'
]
],
'vorname' => [
'exclude' => false,
'label' => 'vorname',
'config' => [
'type' => 'input',
'size' => 30,
'eval' => 'trim'
]
],
'nachname' => [
'exclude' => false,
'label' => 'nachname',
'config' => [
'type' => 'input',
'size' => 30,
'eval' => 'trim'
]
],
'gebaeude' => [
'exclude' => true,
'label' => 'gebaeude',
'config' => [
'type' => 'select',
'renderType' => 'selectSingle',
'foreign_tabel' => 'tx_kkbaybw_domain_model_gebaeude',
],
],
]
];
[/code]
More information about the TYPO3-german
mailing list