123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- <?php
- /**
- * dolphin. Collection of useful PHP skeletons.
- * Copyright (C) 2013-2020 Johannes 'Banana' Keßler
- *
- * https://www.bananas-playground.net
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the COMMON DEVELOPMENT AND DISTRIBUTION LICENSE
- *
- * You should have received a copy of the
- * COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
- * along with this program. If not, see http://www.sun.com/cddl/cddl.html
- */
- /**
- * Class TitleBasics
- * Import the data from imdb dataset title.basics.tsv
- */
- class TitleBasics extends TSVImport {
- /**
- * @inheritDoc
- */
- public function setup() {
- $this->_db_table_name = 'title_basics';
- $this->_db_table_crate_str = "CREATE TABLE `".$this->_db_table_name."` (
- `tconst` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL,
- `titleType` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL,
- `primaryTitle` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL,
- `originalTitle` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL,
- `isAdult` tinyint(1) NOT NULL,
- `startYear` char(4) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL,
- `endYear` char(4) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL,
- `runtimeMinutes` int NOT NULL,
- `genres` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL,
- UNIQUE KEY `tconst` (`tconst`)
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin";
- if($this->_createFulltext) {
- $this->_db_table_after_import_query[] = "ALTER TABLE `" . $this->_db_table_name . "` ADD FULLTEXT (`primaryTitle`)";
- $this->_db_table_after_import_query[] = "ALTER TABLE `" . $this->_db_table_name . "` ADD FULLTEXT (`originalTitle`)";
- $this->_db_table_after_import_query[] = "OPTIMIZE TABLE `" . $this->_db_table_name . "`";
- }
- }
- /**
- * @inheritDoc
- */
- public function queryValuePart($data) {
- $ret = '';
- if(!empty($data)) {
- if(!isset($data[8])) {
- return $ret;
- }
- $ret .= "(
- '".$this->_DB->real_escape_string($data[0])."',
- '".$this->_DB->real_escape_string($data[1])."',
- '".$this->_DB->real_escape_string($data[2])."',
- '".$this->_DB->real_escape_string($data[3])."',
- '".$this->_DB->real_escape_string($data[4])."',
- '".$this->_DB->real_escape_string($data[5])."',
- '".$this->_DB->real_escape_string($data[6])."',
- '".$this->_DB->real_escape_string($data[7])."',
- '".$this->_DB->real_escape_string($data[8])."'
- )";
- }
- return $ret;
- }
- }
|