Php online import mysql Big Data Program

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

21

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

<? Php

Header ("content-type: text/html; charset = UTF-8 ");

Error_reporting (E_ALL );

Set_time_limit (0 );

$ File = './test. SQL ';

$ Data = file ($ file );

 

Echo "<pre> ";

// 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 into 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)

 

*/

Applicability: the SQL file exported by phpmyadmin is too large to be imported to online phpmyadmin.

Upload the program and SQL file to the space and delete it after use.

Share the methods of other netizens. For more information, see

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

$ Rate_info = file ("audio 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 is all the content of this article. I hope you will like it.

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.