Guest User

Untitled

a guest
Jun 19th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.25 KB | None | 0 0
  1. <?php
  2. //Includes
  3. include('includes/class/Movie.class.php');
  4. include('includes/class/Director.class.php');
  5. include('includes/class/MoviesTable.class.php');
  6. include('includes/class/DirectorsTable.class.php');
  7.  
  8. //Evaluate string
  9.  
  10. if($targetNumeric == true)
  11. {
  12.     echo "Acabo de confirmar numeric<br>";
  13.     //Loading Movie objects
  14.     $movie = new MoviesTable;
  15.     //Title search
  16.     $movie->title=$target;
  17.     $rstGetByTitle = $movie->getByTitle();
  18.     //Year search
  19.     $movie->year=$target;
  20.     $rstGetByYear = $movie->getByYear();
  21.     echo "<br>Resultado bsuqeuda por año<br>";
  22.     var_dump($rstGetByYear);
  23.     //Loading Director objects
  24.     $director = new DirectorsTable;
  25.     //Birthday search
  26.     $director->birthday=$target;
  27.     $rstGetByBirthday = $director->getByBirthday();
  28.    
  29.     //Evaluating results
  30.     $searchOnMovies = array("title" => $rstGetByTitle,"year" => $rstGetByYear);
  31.     $searchOnDirectors = array("birthday" => $rstGetByBirthday);
  32.     $rstNumericArray = array (
  33.         "movie" => $searchOnMovies,
  34.         "director" => $searchOnDirectors          
  35.         );
  36.     echo "<br>Dump de array de resultados por categorias<br>";
  37.     var_dump($rstNumericArray);
  38.     foreach($rstNumericArray as $searchType => $searchFound)
  39.     {
  40.         foreach ($searchFound as $category => $targetFound)
  41.         {
  42.             $rstRowsArray = $targetFound->num_rows;
  43.             echo "<br>Estoy mostrando el numero de filas<br>";
  44.             var_dump($rstRowsArray);
  45.             if(empty($rstRowsArray))
  46.                 {
  47.                     echo "<br>Estoy dando nulo porque soy subnormal<br>";
  48.                 }  
  49.                 else
  50.                 {
  51.                     echo "<p>Se han encontrado resultados en el apartado <h2>".$searchType."</h2></p>";
  52.                     for($i=0;$i<count($rstRowsArray);$i++)
  53.                     {
  54.                         echo "<p>Categoría: ".$category."</p>";
  55.                         $rstRow=$targetFound->fetch_assoc();
  56.                         foreach($rstRow as $index => $foundData)
  57.                         {
  58.                             echo $index." : ".$foundData."<br>";
  59.                         }
  60.                     }    
  61.                }
  62.         }
  63.    
  64.     }
  65. }
  66. else
  67. {
  68.     //Loading Movie objects
  69.     $movie = new MoviesTable;
  70.     //Title search
  71.     $movie->title=$target;
  72.     $rstGetByTitle = $movie->getByTitle();
  73.    
  74.     //Genre search
  75.     $movie->genre=$target;
  76.     $rstGetByGenre = $movie->getByGenre();  
  77.    
  78.     //Loading Director objects
  79.     $director = new DirectorsTable;
  80.     //Name search
  81.     $director->name=$target;
  82.     $rstGetByName = $director->getByName();    
  83.     //Surname search
  84.     $director->last_name=$target;
  85.     $rstGetByLastName = $director->getByLast_name();
  86.    
  87.     //Evaluating results
  88.     $searchOnMovies = array("title" => $rstGetByTitle,"genre" => $rstGetByGenre);
  89.     $searchOnDirectors = array("name" => $rstGetByName, "last_name" => $rstGetByLast_name);
  90.     $rstNotNumericArray = array (
  91.         "movie" => $searchOnMovies,
  92.         "director" => $searchOnDirectors          
  93.         );
  94.     echo "<br>Dump de array de resultados por categorias<br>";
  95.     var_dump($rstNumericArray);
  96.     foreach($rstNotNumericArray as $searchType => $searchFound)
  97.     {
  98.         foreach ($searchFound as $category => $targetFound)
  99.         {
  100.             $rstRowsArray = $targetFound->num_rows;
  101.             echo "<br>Estoy mostrando el numero de filas<br>";
  102.             var_dump($rstRowsArray);
  103.             if(empty($rstRowsArray))
  104.                 {
  105.                     echo "<br>Estoy dando nulo porque soy subnormal<br>";
  106.                 }  
  107.                 else
  108.                 {
  109.                     echo "<p>Se han encontrado resultados en el apartado <h2>".$searchType."</h2></p>";
  110.                     for($i=0;$i<count($rstRowsArray);$i++)
  111.                     {
  112.                         echo "<p>Categoría: ".$category."</p>";
  113.                         $rstRow=$targetFound->fetch_assoc();
  114.                         foreach($rstRow as $index => $foundData)
  115.                         {
  116.                             echo $index." : ".$foundData."<br>";
  117.                         }
  118.                     }    
  119.                }
  120.         }
  121.    
  122.     }
  123.    
  124. }
  125.  
  126. ?>
Add Comment
Please, Sign In to add comment