TitleEpisode.class.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. /**
  3. * dolphin. Collection of useful PHP skeletons.
  4. * Copyright (C) 2013-2020 Johannes 'Banana' Keßler
  5. *
  6. * https://www.bananas-playground.net
  7. *
  8. * This program is free software: you can redistribute it and/or modify
  9. * it under the terms of the COMMON DEVELOPMENT AND DISTRIBUTION LICENSE
  10. *
  11. * You should have received a copy of the
  12. * COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
  13. * along with this program. If not, see http://www.sun.com/cddl/cddl.html
  14. */
  15. /**
  16. * Class TitleEpisode
  17. * Import the data from imdb dataset title.episode.tsv
  18. */
  19. class TitleEpisode extends TSVImport {
  20. /**
  21. * @inheritDoc
  22. */
  23. public function setup() {
  24. $this->_db_table_name = 'title_episode';
  25. $this->_db_table_crate_str = "CREATE TABLE `".$this->_db_table_name."` (
  26. `tconst` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL,
  27. `parentTconst` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL,
  28. `seasonNumber` int NOT NULL,
  29. `episodeNumber` int NOT NULL,
  30. UNIQUE KEY `tconst` (`tconst`)
  31. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin";
  32. }
  33. /**
  34. * @inheritDoc
  35. */
  36. public function queryValuePart($data) {
  37. $ret = '';
  38. if(!empty($data)) {
  39. if(!isset($data[3])) {
  40. return $ret;
  41. }
  42. $ret .= "(
  43. '".$this->_DB->real_escape_string($data[0])."',
  44. '".$this->_DB->real_escape_string($data[1])."',
  45. '".$this->_DB->real_escape_string($data[2])."',
  46. '".$this->_DB->real_escape_string($data[3])."'
  47. )";
  48. }
  49. return $ret;
  50. }
  51. }