Browse Source

More workarounds

Dmitry Yu Okunev 4 years ago
parent
commit
3c4905b028
1 changed files with 4 additions and 1 deletions
  1. 4 1
      csv2sql.php

+ 4 - 1
csv2sql.php

@@ -1,6 +1,7 @@
 #!/usr/bin/php
 <?php
 
+define('CHARSET',	'UTF8');
 define('FIELD_SEP',	"\t");
 ini_set("memory_limit", '32M');
 define('ROWSPERLINE',   3000);
@@ -14,10 +15,12 @@ $words=explode(FIELD_SEP, $line);
 
 $fields_count = count($words);
 
+print "SET NAMES ".CHARSET.";\n\n";
+
 print "DROP TABLE IF EXISTS `".$tablename."`;\n";
 print "CREATE TABLE `".$tablename."` (\n";
 print "\t`".implode("` varchar(255),\n\t`", $words).'` varchar(255)';
-print "\n);\n\n";
+print "\n) CHARSET=".CHARSET.";\n\n";
 
 $fieldsstr='`'.implode("`,`",$words).'`';