PHP online import mysql Big Data program _php Tutorial

Source: Internet
Author: User
Tags chop php online

PHP online import mysql Big Data program


PHP online import mysql Big Data program

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21st

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

Header ("Content-type:text/html;charset=utf-8");

Error_reporting (E_all);

Set_time_limit (0);

$file = './test.sql ';

$data =file ($file);

echo "

";

Print_r ($data);

$data _new=array ();

$tmp =array ();

foreach ($data as $line) {

$line =trim ($line);

if (strlen ($line) ==0) {

Continue

}

if (substr ($line, 0,2) = = '--') {

Continue

}

if (substr ($line, 0,2) = = '/* ') {

Continue

}

$tmp []= $line;

if (substr ($line,-1) = = '; ') {

$query =implode (' ', $tmp);

$tmp =array ();

$data _new[]= $query;

}

}

$mysqli =new mysqli (' localhost ', ' root ', ' root ', ' test ');

if ($mysqli->connect_errno) {

Exit (' Database connection failed! ');

}

$mysqli->query ("Set names UTF8");

$error =array ();

foreach ($data _new as $sql) {

$mysqli->query ($sql);

$r = $mysqli->error;

if ($r) $error []= $r;

}

Print_r ($R);

/*

Mysql>alter TABLE tbl2 DISABLE KEYS;

Query OK, 0 rows Affected (0.00 sec)

Mysql>insert to Tbl2 SELECT * from TBL1;

Query OK, 2000000 row Affected (36.30 sec)

records:2000000 duplicates:0 warnings:0

Mysql>alter TABLE tbl2 ENABLE KEYS;

Query OK, 0 rows affected (44.55 sec)

*/

Applicable: phpMyAdmin The exported SQL file is too large to import into the online phpMyAdmin

Upload the program and the SQL file to the space and delete it when you are done.

Share a method of other netizens, small friends can also refer to the next

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

$rate _info = File ("$table. txt");

Print $n _s = Chop ($rate _info[0]);

for ($start =1; $start

{

$value = "";

for ($i = $start; $i < ($start + $n _s-1); $i + +)

{

$tmp = Str_replace ("&&jimmy&&", "", Chop ($rate _info[$i]));

$value. = "'". Addslashes ($tmp). "',";

}

$tmp = Str_replace ("&&jimmy&&", "", Chop ($rate _info[$start + $n _s-1]));

$value. = "'". $tmp. "'";

$query = "INSERT INTO $table values (". $value. ")";

Print mysql_error ();

mysql_query ($query);

Print $start. " ";

}

print "Ostart";

?>

The above mentioned is the whole content of this article, I hope you can like.

http://www.bkjia.com/PHPjc/1015336.html www.bkjia.com true http://www.bkjia.com/PHPjc/1015336.html techarticle php online import mysql Big Data program php online import mysql Big Data program 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 It is the most ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.