1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476
| <?php
if(isset($_GET['series'])) {
$seriesId = $_GET['series'];
}
if(isset($_GET['episodes'])) {
$seriesId = $_GET['episodes'];
}
if(isset($_GET['letter'])) {
$letter = $_GET['letter'];
}
function getPageOnError() {
global $pdo;
global $seriesId;
$sql = <<<SQL
SELECT * FROM SERIES
WHERE seriesId = :seriesId
SQL;
$idQuery = $pdo->prepare($sql);
$idQuery->bindParam(':seriesId', $seriesId, PDO::PARAM_INT);
$idQuery->execute();
$row = $idQuery->fetch();
$seriesIdTest = $row['seriesId'];
return $seriesIdTest;
}
function getLetter() {
global $pdo;
global $letter;
return $letter;
}
function getSeriesList() {
global $pdo;
global $letter;
// Getting the series list from first letter
$sql = <<<SQL
SELECT titleSort, seriesTitle, seriesId, releaseYear FROM SORTLIST
WHERE titleSort RLIKE '^[$letter]'
ORDER BY titleSort, releaseYear
SQL;
$query = $pdo->prepare($sql);
$query->execute();
$seriesList = [];
while (($row = $query->fetch())) {
$seriesList = [
'seriesTitle' => $row['seriesTitle'],
'releaseYear' => $row['releaseYear'],
'seriesId' => $row['seriesId'],
];
$seriesLists[] = $seriesList;
}
return $seriesLists;
}
function getPoster() {
global $pdo;
global $seriesId;
// Getting the series poster, if any
$sql = <<<SQL
SELECT seriesTitle, seriesPoster FROM SERIES
WHERE seriesId = :seriesId
SQL;
$imageQuery = $pdo->prepare($sql);
$imageQuery->bindParam(':seriesId', $seriesId, PDO::PARAM_INT);
$imageQuery->execute();
$row = $imageQuery->fetch();
$seriesPoster = $row['seriesPoster'];
return $seriesPoster;
}
function getTitle() {
global $pdo;
global $seriesId;
// Getting the series title
$sql = <<<SQL
SELECT S.seriesId AS seriesId, SL.seriesTitle AS frenchTitle, S.seriesTitle AS seriesTitle FROM SERIESLIST AS SL
LEFT JOIN SERIES AS S ON S.seriesId = SL.seriesId
WHERE SL.seriesId = :seriesId
SQL;
$titleQuery = $pdo->prepare($sql);
$titleQuery->bindParam(':seriesId', $seriesId, PDO::PARAM_INT);
$titleQuery->execute();
$row = $titleQuery->fetch();
if ($row['frenchTitle'] == $row['seriesTitle']) { // Test if The original an french titles are the same
$title = mb_strtoupper($row['frenchTitle']); // If they are the same display only one uppercase title
} else { // If they're different, display the french title uppercase and the original one lowercase
$title = mb_strtoupper($row['frenchTitle'])." (".$row['seriesTitle'].")";
$limit = "40";
if(strlen($title) <= $limit) { // Test String Lenght
$title = mb_strtoupper($row['frenchTitle'])." (".$row['seriesTitle'].")"; // If the lenght is smaller then limit
} else { // If lenght is bigger, display the title on 2 lines
$title = mb_strtoupper($row['frenchTitle'])."<br>(".$row['seriesTitle'].")";
}
}
$titles = [
'pageTitle' => $row['frenchTitle'],
'title' => $title,
'seriesId' => $row['seriesId'],
];
return $titles;
}
function getSpinOff() {
// Getting the Spin-Off if any
global $pdo;
if(isset($_GET['series'])) {
$seriesId = $_GET['series'];
}
$sql = <<<SQL
SELECT S.seriesId FROM SERIES AS S
JOIN SPINOFF AS SO ON SO.seriesId_spinOff = S.seriesId
WHERE S.seriesId = :seriesId AND SO.seriesId_spinOff = S.seriesId
SQL;
$isSpinOffQuery = $pdo->prepare($sql);
$isSpinOffQuery->bindParam(':seriesId', $seriesId, PDO::PARAM_INT);
$isSpinOffQuery->execute();
$row = $isSpinOffQuery->fetch();
if (isset($row['seriesId'] )) { // Test if the series is a Spin-Off
// Getting the prequel from Query
$sql = <<<SQL
SELECT PL.seriesTitle AS prequel, S.seriesTitle AS spinOff FROM SPINOFF AS SO
JOIN SERIESLIST AS PL ON PL.seriesId = SO.seriesId_prequel
JOIN SERIESLIST AS S ON S.seriesId = SO.seriesId_spinOff
WHERE S.seriesId = :seriesId
SQL;
$spinOffQuery = $pdo->prepare($sql);
$spinOffQuery->bindParam(':seriesId', $seriesId, PDO::PARAM_INT);
$spinOffQuery->execute();
$row = $spinOffQuery->fetch();
$prequel = $row['prequel'];
} else {
$prequel = 0;
}
return $prequel;
}
function getCompany() {
global $pdo;
global $seriesId;
// Get the Company Name if any
$sql = <<<SQL
SELECT companyName AS companyName FROM COMPANY AS C
LEFT JOIN PRODUCTION AS P ON P.companyId = C.companyId
LEFT JOIN SERIES AS S ON S.seriesId = P.seriesId
WHERE S.seriesId = :seriesId
SQL;
$companyQuery = $pdo->prepare($sql);
$companyQuery->bindParam(':seriesId', $seriesId, PDO::PARAM_INT);
$companyQuery->execute();
$rows = $companyQuery->fetchAll();
if(isset($rows[0]['companyName'])) {
$companyName = [];
foreach ($rows as $row) {
$companyName = [
'companyName' => $row['companyName'],
];
$companyNames[] = $companyName;
}
} else {
$companyNames = 0;
}
return $companyNames;
}
function getProducer() {
global $pdo;
global $seriesId;
// Getting the Producer Name if any
$sql = <<<SQL
SELECT personName AS personName FROM PERSON AS P
LEFT JOIN CREW AS C ON C.personId = P.personId
LEFT JOIN ROLE AS R ON R.roleId = C.roleId
LEFT JOIN SERIES AS S ON S.seriesId = C.seriesId
WHERE S.seriesId = :seriesId
AND R.roleId = 1
SQL;
$producerQuery = $pdo->prepare($sql);
$producerQuery->bindParam(':seriesId', $seriesId, PDO::PARAM_INT);
$producerQuery->execute();
$rows = $producerQuery->fetchAll();
if(isset($rows[0]['personName'])) {
$producerName = [];
foreach ($rows as $row) {
$producerName = [
'producerName' => $row['personName'],
];
$producerNames[] = $producerName;
}
} else {
$producerNames = 0;
}
return $producerNames;
}
function getExecProducer() {
global $pdo;
global $seriesId;
// Getting the Executive Producer Name if any
$sql = <<<SQL
SELECT personName AS personName FROM PERSON AS P
LEFT JOIN CREW AS C ON C.personId = P.personId
LEFT JOIN ROLE AS R ON R.roleId = C.roleId
LEFT JOIN SERIES AS S ON S.seriesId = C.seriesId
WHERE S.seriesId = :seriesId
AND R.roleId = 2
SQL;
$execProducerQuery = $pdo->prepare($sql);
$execProducerQuery->bindParam(':seriesId', $seriesId, PDO::PARAM_INT);
$execProducerQuery->execute();
$rows = $execProducerQuery->fetchAll();
if(isset($rows[0]['personName'])) {
$execProducerName = [];
foreach ($rows as $row) {
$execProducerName = [
'execProducerName' => $row['personName'],
];
$execProducerNames[] = $execProducerName;
}
} else {
$execProducerNames = 0;
}
return $execProducerNames;
}
function getDirector() {
global $pdo;
global $seriesId;
// Getting the Director Name if any
$sql = <<<SQL
SELECT personName AS personName FROM PERSON AS P
LEFT JOIN CREW AS C ON C.personId = P.personId
LEFT JOIN ROLE AS R ON R.roleId = C.roleId
LEFT JOIN SERIES AS S ON S.seriesId = C.seriesId
WHERE S.seriesId = :seriesId
AND R.roleId = 3
SQL;
$directorQuery = $pdo->prepare($sql);
$directorQuery->bindParam(':seriesId', $seriesId, PDO::PARAM_INT);
$directorQuery->execute();
$rows = $directorQuery->fetchAll();
if(isset($rows[0]['personName'])) {
$directorName = [];
foreach ($rows as $row) {
$directorName = [
'directorName' => $row['personName'],
];
$directorNames[] = $directorName;
}
} else {
$directorNames = 0;
}
return $directorNames;
}
function getCreator() {
global $pdo;
global $seriesId;
// Getting the Creator Name if any
$crSql = <<<SQL
SELECT personName AS personName FROM PERSON AS P
LEFT JOIN CREW AS C ON C.personId = P.personId
LEFT JOIN ROLE AS R ON R.roleId = C.roleId
LEFT JOIN SERIES AS S ON S.seriesId = C.seriesId
WHERE S.seriesId = :seriesId AND R.roleId = 5
SQL;
$creatorQuery = $pdo->prepare($crSql);
$creatorQuery->bindParam(':seriesId', $seriesId, PDO::PARAM_INT);
$creatorQuery->execute();
$rows = $creatorQuery->fetchAll();
if(isset($rows[0]['personName'])) {
$creator = [];
foreach ($rows as $row) {
$creator = [
'creatorName' => $row['personName'],
];
$creators[] = $creator;
}
} else {
$creators = 0;
}
return $creators;
}
function getOrigCreator() {
global $pdo;
global $seriesId;
// Getting the Original Creator Name if any
$ocSql = <<<SQL
SELECT originalText AS origText FROM ORIG_CREATION AS OC
LEFT JOIN SERIES AS S ON S.originalId = OC.originalId
WHERE S.seriesId = :seriesId
SQL;
$origCreatorQuery = $pdo->prepare($ocSql);
$origCreatorQuery->bindParam(':seriesId', $seriesId, PDO::PARAM_INT);
$origCreatorQuery->execute();
$rows = $origCreatorQuery->fetchAll();
if(isset($rows[0]['origText'])) {
$origCreator = [];
foreach ($rows as $row) {
$origCreator = [
'origCreator' => $row['origText'],
];
$origCreators[] = $origCreator;
}
} else {
$origCreators = 0;
}
return $origCreators;
}
function getCast() {
global $pdo;
global $seriesId;
// Getting Cast List
$sql = <<<SQL
SELECT S.seriesId, CP.characterId AS charId, P.personId, seriesTitle, characterName AS charName, personName, appearanceOrder AS appOrder, period, periodNumber AS periodNum FROM CASTING AS C
JOIN SERIES AS S ON S.seriesId = C.seriesId
JOIN PERSON AS P ON P.personId = C.personId
JOIN CHAR_PLAYED AS CP ON CP.characterId = C.characterId
WHERE S.seriesId = :seriesId
ORDER BY periodNum, appOrder
SQL;
$castQuery = $pdo->prepare($sql);
$castQuery->bindParam(':seriesId', $seriesId, PDO::PARAM_INT);
$castQuery->execute();
$rows = $castQuery->fetchAll();
$cast = [];
foreach ($rows as $row) {
$cast = [
'period' => $row['period'],
'charName' => $row['charName'],
'personName' => $row['personName'],
];
$castList[] = $cast;
}
return $castList;
}
function getFirstAired() {
global $pdo;
global $seriesId;
// Getting the series language
$sql = <<<SQL
SELECT S.seriesId FROM SERIES AS S
JOIN FRENCH_SERIES AS F ON F.seriesId = S.seriesId
WHERE S.seriesId = :seriesId AND F.seriesId = S.seriesId
SQL;
$isFrenchQuery = $pdo->prepare($sql);
$isFrenchQuery->bindParam(':seriesId', $seriesId, PDO::PARAM_INT);
$isFrenchQuery->execute();
$row = $isFrenchQuery->fetch();
// Gettings first aired channel and year
$sql = <<<SQL
SELECT countryName, releaseYear, frenchReleaseYear, channelName, frenchChannelName FROM FIRSTAIRED
WHERE seriesId = :seriesId
SQL;
$airedQuery = $pdo->prepare($sql);
$airedQuery->bindParam(':seriesId', $seriesId, PDO::PARAM_INT);
$airedQuery->execute();
if (isset($row['seriesId'] )) { // Test if it's a french series
$firstAired = [];
$row = $airedQuery->fetch();
$firstAired = [
'countryName' => 'France',
'channelName' => $row['channelName'],
'releaseYear' => $row['releaseYear'],
];
$firstAiredInfos[] = $firstAired;
return $firstAiredInfos;
} else {
$firstAired = [];
$row = $airedQuery->fetch();
$firstAired = [
'countryName' => $row['countryName'],
'channelName' => $row['channelName'],
'releaseYear' => $row['releaseYear'],
'frenchChannelName' => $row['frenchChannelName'],
'frenchReleaseYear' => $row['frenchReleaseYear'],
];
$firstAiredInfos[] = $firstAired;
return $firstAiredInfos;
}
}
function getSeasonNumber() {
global $pdo;
global $seriesId;
// Getting Season Number
$sql = <<<SQL
SELECT S.seriesId, SN.seasonId, SN.seasonNumber, E.seasonId FROM SEASON AS SN
JOIN EPISODE AS E ON E.seriesId = S.seriesId
JOIN SERIES AS S ON S.seriesId = E.seriesId
WHERE S.seriesId = :seriesId
ORDER BY seasonId
SQL;
$seasonQuery = $pdo->prepare($sql);
$seasonQuery->bindParam(':seriesId', $seriesId, PDO::PARAM_INT);
$seasonQuery->execute();
$rows = $seasonQuery->fetchAll();
$season = [];
foreach ($rows as $row) {
$season = [
'seasonNumber' => $row['seasonNumber'],
];
$seasonList[] = $season;
}
return $seasonList;
}
function getEpisodes() {
global $pdo;
global $seriesId;
// Getting Episodes List
$sql = <<<SQL
SELECT S.seriesId, E.episodeId AS epId, E.episodeNumber, E.seasonEpisodeNumber, SN.seasonId AS seasonId, SN.seasonNumber as SeasonNumber FROM EPISODE AS E
JOIN SERIES AS S ON S.seriesId = E.seriesId
JOIN SEASON AS SN ON SN.seasonId = E.seasonId
WHERE S.seriesId = :seriesId
ORDER BY episodeNumber, seasonEpisodeNumber
SQL;
$episodesQuery = $pdo->prepare($sql);
$episodesQuery->bindParam(':seriesId', $seriesId, PDO::PARAM_INT);
$episodesQuery->execute();
$rows = $episodesQuery->fetchAll();
$episode = [];
foreach ($rows as $row) {
$episode = [
'epNumber' => $row['episodeNumber'],
'seasonEpNumber' => $row['seasonEpisodeNumber'],
'episodeTitle' => $row['episodeTitle'],
];
$episodeList[] = $episode;
}
return $episodeList;
}
?> |
Partager