1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- <?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 NameBasics
- * Import the data from imdb dataset name.basics.tsv
- */
- class NameBasics extends TSVImport {
- /**
- * @inheritDoc
- */
- public function setup() {
- $this->_db_table_name = 'name_basics';
- $this->_db_table_crate_str = "CREATE TABLE `".$this->_db_table_name."` (
- `nconst` varchar(16) COLLATE utf8mb4_bin NOT NULL,
- `primaryName` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL,
- `birthYear` year NOT NULL,
- `deathYear` year NOT NULL,
- `primaryProfession` text CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL,
- `knownForTitles` text CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL,
- UNIQUE KEY `nconst` (`nconst`)
- ) 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 (`primaryName`)";
- $this->_db_table_after_import_query[] = "OPTIMIZE TABLE `" . $this->_db_table_name . "`";
- }
- }
- /**
- * @inheritDoc
- */
- public function queryValuePart($data) {
- $ret = '';
- if(!empty($data)) {
- if(!isset($data[5])) {
- 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])."'
- )";
- }
- return $ret;
- }
- }
|