[TYPO3-mvc] Database queries/mapping with associated tables
Michael Ruhdorfer
michael.ruhdorfer.1line at gmail.com
Wed Aug 18 08:41:29 CEST 2010
hi all,
i'm afraid i don't really understand the way how extbase deals with database
relations.
i have a structure something like this:
table_company
- title
- employees*
- country*
- branches*
table_employees
- name
- company*
table_branches
- name
table_country
- name
- regions*
table_region
- name
* means that data is mapped from other tables
-> 1 company has n employees
-> 1 company is in 1 country
-> 1 company is in 1 region
-> 1 company has n branches
-> 1 country has n regions
i need a list with all employees something like that:
<:f foreach="{company.branches}" as="{branch}">
employee {employees.name}: Richard Meyer
company {company.name}: Industrial Electronics
country {company.country.name}: Netherlands
region {company.country.regions.name}: Friesland
branches {branch.name}: Electronics
...
branches {branch.name}: Electricity
</f:foreach>
that works so far
{branch.name} is only once inside the foreach - the data inside the {}
braces is just for relation demonstration
so because of the mapping it works with $this->companyRepository->findAll()
to access data the following way:
$name = $company->getName();
$employees = $company->getEmployees();
foreach($employees as $e)
$e->getName();
...
now i want to filter the results by countries / branches / regions
i have been thinking on something like this:
$query->matching(
$query->equals('tx_myextension_domain_model_company.country.uid',
$countryId)
);
but it doesn't work... i have to do that in the repository - not in the
model, right?
i'd be thankful on any hint,
thx, michael
More information about the TYPO3-project-typo3v4mvc
mailing list