Teiger: mehrere Probleme mit Funktion

Beitrag lesen

Hallo,

also ich habe 3 Probleme mit folgende Funktion:

function retrieveEventDetails($id)
 {

$this->db->raw_query("SELECT e.*, c.*, pe.picture, pe.description
                        FROM lnk_event_conductor AS lec, contacts AS c, events e
                              LEFT JOIN lnk_event_pic AS lep ON (e.id = lep.id_event)
                              LEFT JOIN pictures_events AS pe ON (lep.id_event = pe.id)
                (e.lang = '".$this->language."')
                              AND (e.id = '".$id."')
                              AND (e.id = lec.id_event)
                              AND (lec.id_conductor = c.id)");

/*
  $this->db->select("e.*, c.*, pe.picture, pe.description",
                    "lnk_event_conductor AS lec, contacts AS c, events e
                           LEFT JOIN lnk_event_pic AS lep ON (e.id = lep.id_event)
                           LEFT JOIN pictures_events AS pe ON (lep.id_event = pe.id)",
         "(e.lang = '".$this->language."')
                           AND (e.id = '".$id."')
                           AND (e.id = lec.id_event)
                           AND (lec.id_conductor = c.id)",
         "", "", "", "");
  */

$eventDetails = $this->db->fetch_array();
  $eventDetails['date_s'] = $this->makeGermanDate($eventDetails['date_s']);
  $eventDetails['date_e'] = $this->makeGermanDate($eventDetails['date_e']);

if($eventDetails['time_s'] == '00:00:00')
  {
   $eventDetails['time_s'] = '--';
  }
  if($eventDetails['time_e'] == '00:00:00')
  {
   $eventDetails['time_e'] = '--';
  }

$this->assignVars('eventDetails', $eventDetails);
 }

1)Der auskommentierte Funktionsaufruf funktioniert. Ich möchte die Klasse aber mit dem normalen query aufrufen(darüber).

Es kommt folgende Fehlermeldung:

SELECT e.*, c.*, pe.picture, pe.description FROM lnk_event_conductor AS lec, contacts AS c, events e LEFT JOIN lnk_event_pic AS lep ON (e.id = lep.id_event) LEFT JOIN pictures_events AS pe ON (lep.id_event = pe.id) (e.lang = 'de') AND (e.id = '20') AND (e.id = lec.id_event) AND (lec.id_conductor = c.id)
You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '(e.lang = 'de') AND (e.id = '20'
1064

  1. In der mysql DB sind die Zeiten im time Format gespeichert(00:00:00). Wie bekomme ich mit php den letzten Doppelpunkt und die Sekunden weg ?

3)Die Tabelle lnk_event_conductor enthält in der ersten Spalte die ID  eines Events(Seminar) und in der zweiten Spalte die ID des conductors(Seminarleiters) nun gibt es aber mehrere Seminarleiter für ein Event. Aber der query nimmt immer nur die erste die er findet.

Wie muss man das abändern ?

Danke