1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
if (grep {$_ eq 'experience.country'} ($self->{field1}, $self->{field2}, $self->{field3})) {
$sqlquery .= q#
JOIN has_regional_experience ON people.ID_person = has_regional_experience.ID_person
JOIN countries AS experience ON has_regional_experience.ID_country = experience.ID_country
#;
}
if (grep {$_ eq 'nationality.country'} ($self->{field1}, $self->{field2}, $self->{field3})) {
$sqlquery .= q#
JOIN belongs_to ON people.ID_person = belongs_to.ID_person
JOIN countries AS nationality ON belongs_to.ID_country = nationality.ID_country
#;
}
if (grep {$_ eq 'expertise'} ($self->{field1}, $self->{field2}, $self->{field3})) {
$sqlquery .= q#
JOIN owns ON people.ID_person = owns.ID_person
JOIN expertise ON owns.ID_expertise = expertise.ID_expertise
#;
}
if (grep {$_ eq 'language'} ($self->{field1}, $self->{field2}, $self->{field3})) {
$sqlquery .= q#
JOIN spoke ON people.ID_person = spoke.ID_person
JOIN languages ON spoke.ID_language = languages.ID_language
#;
}
if (grep {$_ eq 'donor'} ($self->{field1}, $self->{field2}, $self->{field3})) {
$sqlquery .= q#
JOIN worked_for ON people.ID_person = worked_for.ID_person
JOIN donors ON worked_for.ID_donor = donors.ID_donor
#;
}
Okay, hier die Lösung zu meinem kleinen Problem. Wie sich herausstellte bringen die JOINs noch einen Seiteneffekt mit sich. Es handelt sich ja um eine m:n-Auflösung - ist aber n==0 - also existiert keine Zuordnung auf dieser Seite bekommt man auch keinen Datensatz von der Abfrage. Eigentlich logisch aber manchmal dauert es eben etwas länger.