Commit 5327be1c authored by Nico Schallehn's avatar Nico Schallehn

debug

parent ee846e19
...@@ -50,7 +50,7 @@ class MediaDBViewerAPI{ ...@@ -50,7 +50,7 @@ class MediaDBViewerAPI{
public function API_GetDataListe($GET_arr, $POST_arr =""){ public function API_GetDataList($GET_arr, $POST_arr =""){
if(!isset($GET_arr['Tabelle']) OR ($GET_arr['Tabelle'] == "")) { if(!isset($GET_arr['Tabelle']) OR ($GET_arr['Tabelle'] == "")) {
return $this->error(1004); return $this->error(1004);
} }
...@@ -60,6 +60,7 @@ class MediaDBViewerAPI{ ...@@ -60,6 +60,7 @@ class MediaDBViewerAPI{
isset($GET_arr['SchauspielerID']) OR isset($GET_arr['Schauspieler']) OR isset($GET_arr['Suche']) OR isset($GET_arr['SchauspielerSuche']) ) isset($GET_arr['SchauspielerID']) OR isset($GET_arr['Schauspieler']) OR isset($GET_arr['Suche']) OR isset($GET_arr['SchauspielerSuche']) )
AND $GET_arr['Tabelle'] == "Filme" ){ // Filterung nur für Tablle Filme!! AND $GET_arr['Tabelle'] == "Filme" ){ // Filterung nur für Tablle Filme!!
$first = true; $first = true;
$imdbArrToCompar = 0;
$Where = "WHERE "; $Where = "WHERE ";
if(isset($GET_arr['imdbID']) AND is_numeric($GET_arr['imdbID'])){ if(isset($GET_arr['imdbID']) AND is_numeric($GET_arr['imdbID'])){
...@@ -80,51 +81,80 @@ class MediaDBViewerAPI{ ...@@ -80,51 +81,80 @@ class MediaDBViewerAPI{
$Query = 'SELECT group_concat(fg.imdbID) AS imdbIDs FROM FilmGenre AS fg JOIN Genre AS g ON fg.genreID = g.genreID WHERE g.genreID IN ('.$GET_arr['GenreID'].') '; $Query = 'SELECT group_concat(fg.imdbID) AS imdbIDs FROM FilmGenre AS fg JOIN Genre AS g ON fg.genreID = g.genreID WHERE g.genreID IN ('.$GET_arr['GenreID'].') ';
$Genre = $this->DB_Objekt->query($Query); $Genre = $this->DB_Objekt->query($Query);
if($this->DB_Objekt->error != ""){ return $this->error(1005, $this->DB_Objekt->error);} if($this->DB_Objekt->error != ""){ return $this->error(1005, $this->DB_Objekt->error);}
$GenreArr = $Genre->fetch_array(); $imdbIDString = $Genre->fetch_array();
$Where .= (strlen($GenreArr["imdbIDs"])>0?($first?"":" AND ").str_replace(",)", ")", 'imdbID in ('.$GenreArr["imdbIDs"].')'): ($first?" 0 ":"")); //$Where .= (strlen($GenreArr["imdbIDs"])>0?($first?"":" AND ").str_replace(",)", ")", 'imdbID in ('.$GenreArr["imdbIDs"].')'): ($first?" 0 ":""));
$first = false; //$first = false;
$imdbArr[$imdbArrToCompar++] = explode(",", $imdbIDString);
} }
if( isset($GET_arr['Genre'])){ if( isset($GET_arr['Genre'])){
$Query = 'SELECT group_concat(fg.imdbID) AS imdbIDs FROM FilmGenre AS fg JOIN Genre AS g ON fg.genreID = g.genreID WHERE g.engname IN ("'.str_replace(",", '","', $GET_arr['Genre']).'") '; $Query = 'SELECT group_concat(fg.imdbID) AS imdbIDs FROM FilmGenre AS fg JOIN Genre AS g ON fg.genreID = g.genreID WHERE g.engname IN ("'.str_replace(",", '","', $GET_arr['Genre']).'") ';
$Genre = $this->DB_Objekt->query($Query); $Genre = $this->DB_Objekt->query($Query);
if($this->DB_Objekt->error != ""){ return $this->error(1005, $this->DB_Objekt->error);} if($this->DB_Objekt->error != ""){ return $this->error(1005, $this->DB_Objekt->error);}
$GenreArr = $Genre->fetch_array(); $imdbIDString = $Genre->fetch_array();
$Where .= (strlen($GenreArr["imdbIDs"])>0?($first?"":" AND ").str_replace(",)", ")", 'imdbID in ('.$GenreArr["imdbIDs"].')'): ($first?" 0 ":"")); //$Where .= (strlen($GenreArr["imdbIDs"])>0?($first?"":" AND ").str_replace(",)", ")", 'imdbID in ('.$GenreArr["imdbIDs"].')'): ($first?" 0 ":""));
$first = false; //$first = false;
$imdbArr[$imdbArrToCompar++] = explode(",", $imdbIDString);
} }
if(isset($GET_arr['SchauspielerID'])){ if(isset($GET_arr['SchauspielerID'])){
$Query = 'SELECT group_concat(fs.imdbID) AS imdbIDs FROM FilmSchauspieler AS fs JOIN Schauspieler AS s ON fs.schauspielerID = s.schauspielerID WHERE s.schauspielerID IN ('.$GET_arr['SchauspielerID'].') '; $Query = 'SELECT group_concat(fs.imdbID) AS imdbIDs FROM FilmSchauspieler AS fs JOIN Schauspieler AS s ON fs.schauspielerID = s.schauspielerID WHERE s.schauspielerID IN ('.$GET_arr['SchauspielerID'].') ';
$this->DebugOut( $Query); $this->DebugOut( $Query);
$Schauspieler = $this->DB_Objekt->query($Query); $Schauspieler = $this->DB_Objekt->query($Query);
if($this->DB_Objekt->error != ""){ return $this->error(1005, $this->DB_Objekt->error);} if($this->DB_Objekt->error != ""){ return $this->error(1005, $this->DB_Objekt->error);}
$SchauspielerArr = $Schauspieler->fetch_array(); $imdbIDString = $Schauspieler->fetch_array();
//echo $GenreArr["imdbIDs"]; //echo $GenreArr["imdbIDs"];
$Where .= (strlen($SchauspielerArr["imdbIDs"])>0?($first?"":" AND ").str_replace(",)", ")", 'imdbID in ('.$SchauspielerArr["imdbIDs"].')'): ($first?" 0 ":"")); //$Where .= (strlen($SchauspielerArr["imdbIDs"])>0?($first?"":" AND ").str_replace(",)", ")", 'imdbID in ('.$SchauspielerArr["imdbIDs"].')'): ($first?" 0 ":""));
$first = false; //$first = false;
$imdbArr[$imdbArrToCompar++] = explode(",", $imdbIDString);
} }
if( isset($GET_arr['Schauspieler'])){ if( isset($GET_arr['Schauspieler'])){
$Query = 'SELECT group_concat(fs.imdbID) AS imdbIDs FROM FilmSchauspieler AS fs JOIN Schauspieler AS s ON fs.schauspielerID = s.schauspielerID WHERE s.name IN ("'.str_replace(",", '","', $GET_arr['Schauspieler']).'") '; $Query = 'SELECT group_concat(fs.imdbID) AS imdbIDs FROM FilmSchauspieler AS fs JOIN Schauspieler AS s ON fs.schauspielerID = s.schauspielerID WHERE s.name IN ("'.str_replace(",", '","', $GET_arr['Schauspieler']).'") ';
//$this->DebugOut($Query." >>Zeile:".__LINE__); //$this->DebugOut($Query." >>Zeile:".__LINE__);
$Schauspieler = $this->DB_Objekt->query($Query); $Schauspieler = $this->DB_Objekt->query($Query);
if($this->DB_Objekt->error != ""){ return $this->error(1005, $this->DB_Objekt->error);} if($this->DB_Objekt->error != ""){ return $this->error(1005, $this->DB_Objekt->error);}
$SchauspielerArr = $Schauspieler->fetch_array(); $imdbIDString = $Schauspieler->fetch_array();
//$this->DebugOut($SchauspielerArr["imdbIDs"].">".strlen($SchauspielerArr["imdbIDs"])." >>Zeile:".__LINE__); //$this->DebugOut($SchauspielerArr["imdbIDs"].">".strlen($SchauspielerArr["imdbIDs"])." >>Zeile:".__LINE__);
$Where .= (strlen($SchauspielerArr["imdbIDs"])>0?($first?"":" AND ").str_replace(",)", ")", 'imdbID in ('.$SchauspielerArr["imdbIDs"].')'): ($first?" 0 ":"")); //$Where .= (strlen($SchauspielerArr["imdbIDs"])>0?($first?"":" AND ").str_replace(",)", ")", 'imdbID in ('.$SchauspielerArr["imdbIDs"].')'): ($first?" 0 ":""));
$first = false; //$first = false;
$imdbArr[$imdbArrToCompar++] = explode(",", $imdbIDString);
} }
if( isset($GET_arr['SchauspielerSuche'])){ if( isset($GET_arr['SchauspielerSuche'])){
$Query = 'SELECT group_concat(fs.imdbID) AS imdbIDs FROM FilmSchauspieler AS fs JOIN Schauspieler AS s ON fs.schauspielerID = s.schauspielerID WHERE s.name LIKE "%'.$GET_arr['SchauspielerSuche'].'%" '; $Query = 'SELECT group_concat(fs.imdbID) AS imdbIDs FROM FilmSchauspieler AS fs JOIN Schauspieler AS s ON fs.schauspielerID = s.schauspielerID WHERE s.name LIKE "%'.$GET_arr['SchauspielerSuche'].'%" ';
//$this->DebugOut($Query." >>Zeile:".__LINE__); //$this->DebugOut($Query." >>Zeile:".__LINE__);
$Schauspieler = $this->DB_Objekt->query($Query); $Schauspieler = $this->DB_Objekt->query($Query);
if($this->DB_Objekt->error != ""){ return $this->error(1005, $this->DB_Objekt->error);} if($this->DB_Objekt->error != ""){ return $this->error(1005, $this->DB_Objekt->error);}
$SchauspielerArr = $Schauspieler->fetch_array(); $imdbIDString = $Schauspieler->fetch_array();
//$this->DebugOut($SchauspielerArr["imdbIDs"].">".strlen($SchauspielerArr["imdbIDs"])." >>Zeile:".__LINE__); //$this->DebugOut($SchauspielerArr["imdbIDs"].">".strlen($SchauspielerArr["imdbIDs"])." >>Zeile:".__LINE__);
$Where .= (strlen($SchauspielerArr["imdbIDs"])>0?($first?"":" AND ").str_replace(",)", ")", 'imdbID in ('.$SchauspielerArr["imdbIDs"].')'): ($first?" 0 ":"")); //$Where .= (strlen($SchauspielerArr["imdbIDs"])>0?($first?"":" AND ").str_replace(",)", ")", 'imdbID in ('.$SchauspielerArr["imdbIDs"].')'): ($first?" 0 ":""));
$first = false; //$first = false;
$imdbArr[$imdbArrToCompar++] = explode(",", $imdbIDString);
} }
//TODO Hier gemeinsame Auswertung für die imdbIDs von Genre und Schauspieler!!! //TODO Hier gemeinsame Auswertung für die imdbIDs von Genre und Schauspieler!!!
switch ($imdbArrToCompar){ // Wenn es nur eine imDB Array Liste gibt...
case 1:// Verfahre wie Früher:
$this->DebugOut("nur eine Bedingung >>Zeile:".__LINE__);
var_dump($imdbArr[0]);
$Where .= (strlen($SchauspielerArr["imdbIDs"])>0?($first?"":" AND ").str_replace(",)", ")", 'imdbID in ('.implode(",",$imdbArr[0]).')'): ($first?" 0 ":""));
$first = false;
break;
case 2:
$this->DebugOut("2 Bedingung >>Zeile:".__LINE__);
var_dump(array_intersect($imdbArr[0],$imdbArr[1]));
$Where .= (strlen($SchauspielerArr["imdbIDs"])>0?($first?"":" AND ").str_replace(",)", ")", 'imdbID in ('.implode(",",array_intersect($imdbArr[0],$imdbArr[1])).')'): ($first?" 0 ":""));
$first = false;
break;
case 3:
break;
}
} }
// Überprüfen ob Schauspieler oder Genre gefordert wird // Überprüfen ob Schauspieler oder Genre gefordert wird
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment