Moin,
also in dem Tracker habe ich nichts passendes gefunden... war mir aber auch nicht 100%ig sicher nach was ich gucken soll.
Jedenfalls habe ich den Query mal etwas aufgebohrt. Mein Thema "Doppeltes Join" ist auch etwas fehl. Die Reihenfolge der Joins ist fehlerhaft. Wenn ich diese umdrehe gibt es zumindest keine Fehler mehr...
Jetzt habe ich aber das Problem das 0 Ergebnisse geliefert werden anstatt 1. Das kommt weil das Feld "coordinatingInstitute" aus der Projects Tabelle nicht berücksichtigt wird.
Was mache ich falsch bzw. kann wie kann ich das lösen? Idealerweise über das Extbase Query Object... Denn vielleicht baue ich da ja schon den Query falsch zusammen der dann den "Bug" verursacht?
Hier mal der Query mit den Joins in der korrekten Reihenfolge (aber 0 ergebnisse) und mein Extbase Query Aufruf (welche den fehlerhaften query) produziert.
SELECT DISTINCT tx_nnctcp_domain_model_project.*
FROM tx_nnctcp_domain_model_project
LEFT JOIN tx_nnctcp_project_institute_mm
ON tx_nnctcp_domain_model_project.uid = tx_nnctcp_project_institute_mm.uid_local
LEFT JOIN tx_nnctcp_domain_model_institute
ON tx_nnctcp_project_institute_mm.uid_foreign = tx_nnctcp_domain_model_institute.uid
LEFT JOIN tx_nnctcp_domain_model_country
ON tx_nnctcp_domain_model_institute.country = tx_nnctcp_domain_model_country.uid
WHERE (
(
tx_nnctcp_domain_model_project.pid IN ('73')
AND
tx_nnctcp_domain_model_project.refid LIKE '%1225%'
)
AND tx_nnctcp_domain_model_country.uid = '5'
)
AND tx_nnctcp_domain_model_project.deleted = 0
AND tx_nnctcp_domain_model_project.t3ver_state <= 0
AND tx_nnctcp_domain_model_project.pid <> -1
AND tx_nnctcp_domain_model_project.hidden = 0
AND tx_nnctcp_domain_model_project.starttime <= 1360828500
AND
(
tx_nnctcp_domain_model_project.endtime = 0
OR
tx_nnctcp_domain_model_project.endtime > 1360828500
)
AND tx_nnctcp_domain_model_project.sys_language_uid IN (0,-1)
AND tx_nnctcp_domain_model_project.pid IN (73, 77, 78-)
AND tx_nnctcp_domain_model_institute.deleted = 0
AND tx_nnctcp_domain_model_institute.t3ver_state <= 0
AND tx_nnctcp_domain_model_institute.pid <> -1
AND tx_nnctcp_domain_model_institute.hidden = 0
AND tx_nnctcp_domain_model_institute.starttime <= 1360828500
AND
(
tx_nnctcp_domain_model_institute.endtime = 0
OR
tx_nnctcp_domain_model_institute.endtime>1360828500
)
AND tx_nnctcp_domain_model_institute.sys_language_uid IN (0,-1)
AND tx_nnctcp_domain_model_institute.pid IN (73, 77, 78-)
AND tx_nnctcp_domain_model_country.deleted = 0
AND tx_nnctcp_domain_model_country.t3ver_state <= 0
AND tx_nnctcp_domain_model_country.pid <> -1
AND tx_nnctcp_domain_model_country.hidden = 0
AND tx_nnctcp_domain_model_country.starttime <= 1360828500
AND
(
tx_nnctcp_domain_model_country.endtime = 0
OR
tx_nnctcp_domain_model_country.endtime > 1360828500
)
AND tx_nnctcp_domain_model_country.sys_language_uid IN (0,-1)
AND tx_nnctcp_domain_model_country.pid IN (73, 77, 78-)
ORDER BY tx_nnctcp_domain_model_project.refid ASC
public function findBySearch(array $sterm,$sorting = "title",$order = "ASC") {
// Ggf. überschreibt der Benutzer Query
if ( ($userQuery = $this->getUserQuery(__FUNCTION__)) != false ) return $this->executeUserQuery($userQuery);
// Query vorbereiten
$query = $this->createQuery();
$logicalAnd = array($query->in('pid',$this->getPidList(false,__FUNCTION__)));
// Suchkriterien bilden
if ( $sterm['title'] != '' ) array_push($logicalAnd, $query->like('title','%'.$sterm['title'].'%'));
if ( $sterm['refid'] > 0 ) array_push($logicalAnd, $query->like('refid','%'.(integer)$sterm['refid'].'%'));
if ( $sterm['subject'] > 0 ) array_push($logicalAnd, $query->equals('subjects.uid',(integer)$sterm['subject']));
if ( $sterm['collaboration'] > -1 ) array_push($logicalAnd, $query->equals('collaboration_type',(integer)$sterm['collaboration']));
if ( $sterm['institute'] > 0 ) array_push($logicalAnd, $query->equals('institutes.uid',(integer)$sterm['institute']));
if ( $sterm['status'] > -1 ) array_push($logicalAnd, $query->equals('status',(integer)$sterm['status']));
if ( $sterm['country'] > 0 ) array_push($logicalAnd, $query->logicalOr(
# DEBUG: Dies führt zu einem doppelten Join und damit SQL Fehler, Lösung???
$query->equals('coordinatingInstitute.country.uid',(integer)$sterm['country']),
$query->equals('institutes.country.uid',(integer)$sterm['country'])
));
// Sortierung festlegen
$order = ( $order === 'ASC' ) ? Tx_Extbase_Persistence_QueryInterface::ORDER_ASCENDING : Tx_Extbase_Persistence_QueryInterface::ORDER_DESCENDING;
// Ausführen und Ergebnis
return $query->matching($query->logicalAnd($logicalAnd))->execute();
}