TitlePrincipals.class.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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 TitlePrincipals
  17. * Import the data from imdb dataset title.principals.tsv
  18. */
  19. class TitlePrincipals extends TSVImport {
  20. /**
  21. * @inheritDoc
  22. */
  23. public function setup() {
  24. $this->_db_table_name = 'title_principals';
  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. `ordering` int NOT NULL,
  28. `nconst` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL,
  29. `category` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL,
  30. `job` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL,
  31. `characters` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL,
  32. UNIQUE KEY `tconst` (`tconst`,`ordering`)
  33. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin";
  34. }
  35. /**
  36. * @inheritDoc
  37. */
  38. public function queryValuePart($data) {
  39. $ret = '';
  40. if(!empty($data)) {
  41. if(!isset($data[5])) {
  42. return $ret;
  43. }
  44. $ret .= "(
  45. '".$this->_DB->real_escape_string($data[0])."',
  46. '".$this->_DB->real_escape_string($data[1])."',
  47. '".$this->_DB->real_escape_string($data[2])."',
  48. '".$this->_DB->real_escape_string($data[3])."',
  49. '".$this->_DB->real_escape_string($data[4])."',
  50. '".$this->_DB->real_escape_string($data[5])."'
  51. )";
  52. }
  53. return $ret;
  54. }
  55. }