Zum Inhalt springen

von exec_SELECTquery zu pi_exec_query mit Tabellenrelation

Erstellt am 22. Mai 2007 · 15 Antworten · letzte Antwort am 24. Mai 2007

Tags: Frage

jenses ·

$this->cObj->enableFields() kommt nicht mit den Tabellen-Aliassen(heißen die so? also m und s) klar.
Also return von $this->cObj->enableFields per RegExp bearbeiten,
oder Abfrage selber konstruieren,
die Vorlage liefert ja class.t3lib_page.php->enableFields().
Oder aber die Relation zwischen deinen Tabellen auf solidere Füße stellen,
z.B. mit mm-Relationen. Dafür gibt´s dann auch wieder die passenden Abfragefunktionen.

steffenk ·

stimmt. (Aliases sollte es sein 🙂 )
da hilft z.B.

str_replace('tx_kreuzfahrtspecials_main','m',$this->cObj->enableFields('tx_kreuzfahrtspecials_main'))
michelsweb ·

Die Ausgabe der Query lautet übrigens:

|SELECT m.*, s.shipname AS ship_clear FROM tx_kreuzfahrtspecials_main m, tx_kreuzfahrtspecials_ship s WHERE m.ship=s.uid AND m.deleted=0 AND m.hidden=0 AND (m.starttime<=1179940836) AND (m.endtime=0 OR m.endtime>1179940836) AND (m.fe_group='' OR m.fe_group IS NULL OR m.fe_group='0' OR (m.fe_group LIKE '%,0,%' OR m.fe_group LIKE '0,%' OR m.fe_group LIKE '%,0' OR m.fe_group='0') OR (m.fe_group LIKE '%,-1,%' OR m.fe_group LIKE '-1,%' OR m.fe_group LIKE '%,-1' OR m.fe_group='-1')) ORDER BY m.priority ASC|
michelsweb ·

Das soll dann vermutlich so aussehen:

|SELECT tx_kreuzfahrtspecials_main.*, tx_kreuzfahrtspecials_ship.shipname AS ship_clear FROM tx_kreuzfahrtspecials_main, tx_kreuzfahrtspecials_ship WHERE tx_kreuzfahrtspecials_main.ship=tx_kreuzfahrtspecials_ship.uid AND tx_kreuzfahrtspecials_main.deleted=0 AND tx_kreuzfahrtspecials_main.hidden=0 AND (tx_kreuzfahrtspecials_main.starttime<=1179942133) AND (tx_kreuzfahrtspecials_main.endtime=0 OR tx_kreuzfahrtspecials_main.endtime>1179942133) AND (tx_kreuzfahrtspecials_main.fe_group='' OR tx_kreuzfahrtspecials_main.fe_group IS NULL OR tx_kreuzfahrtspecials_main.fe_group='0' OR (tx_kreuzfahrtspecials_main.fe_group LIKE '%,0,%' OR tx_kreuzfahrtspecials_main.fe_group LIKE '0,%' OR tx_kreuzfahrtspecials_main.fe_group LIKE '%,0' OR tx_kreuzfahrtspecials_main.fe_group='0') OR (tx_kreuzfahrtspecials_main.fe_group LIKE '%,-1,%' OR tx_kreuzfahrtspecials_main.fe_group LIKE '-1,%' OR tx_kreuzfahrtspecials_main.fe_group LIKE '%,-1' OR tx_kreuzfahrtspecials_main.fe_group='-1')) AND tx_kreuzfahrtspecials_ship.deleted=0 AND tx_kreuzfahrtspecials_ship.hidden=0 AND (tx_kreuzfahrtspecials_ship.starttime<=1179942133) AND (tx_kreuzfahrtspecials_ship.endtime=0 OR tx_kreuzfahrtspecials_ship.endtime>1179942133) AND (tx_kreuzfahrtspecials_ship.fe_group='' OR tx_kreuzfahrtspecials_ship.fe_group IS NULL OR tx_kreuzfahrtspecials_ship.fe_group='0' OR (tx_kreuzfahrtspecials_ship.fe_group LIKE '%,0,%' OR tx_kreuzfahrtspecials_ship.fe_group LIKE '0,%' OR tx_kreuzfahrtspecials_ship.fe_group LIKE '%,0' OR tx_kreuzfahrtspecials_ship.fe_group='0') OR (tx_kreuzfahrtspecials_ship.fe_group LIKE '%,-1,%' OR tx_kreuzfahrtspecials_ship.fe_group LIKE '-1,%' OR tx_kreuzfahrtspecials_ship.fe_group LIKE '%,-1' OR tx_kreuzfahrtspecials_ship.fe_group='-1')) ORDER BY m.priority ASC|
Stoneage ·

Nur so ein Tip: Ich würde so Namen wie tx_kreuzfahrtspecials_main nach t24n abkürzen. 24 ist dabei die Anzahl der Buchstaben zwischen Anfang und Ende. Das erhöht die Lesbarkeit enorm, und ist einfach cooler.