PHP uye MySQL: Export Mubvunzo kune Tab Yakagadziriswa Faira

mysql php marogo

Vhiki rino ini ndaida kuvaka peji iro rinongochengeta chero mhinduro kana tafura muTab Delimited faira. Mazhinji emienzaniso kunze kwemambure ane makoramu akaomeswa-kodhi.

Mune yangu nyaya, ini ndaida kuti makoramu ave nesimba saka ndaifanira kutanga ndavhura nemumatafura etafura ese mazita kuti ndivakise iwo musoro wemusoro nemazita emakoramu, ndobva ndavhurika kuburikidza nezvose zvinyorwa zvemitsara yedhata yakasara. Ini zvakare ndakaisa musoro kuitira kuti bhurawuza ritange kurodha pasi faira mune iyo filetype (txt) ine zita reiyo zuva refaira uye timestamp.

Ini ndakasiya dhatabhesi yakavhurika uye yekuvhara kubatana, asi heino mhedzisiro kodhi yakashanda chaizvo.

$ nhasi = zuva ("YmdHi");
musoro ("Zvemukati-mhando: kunyorera / octet-rwizi");
musoro ("Zvemukati-Disposition: chinongedzo; filename = \" ". $ nhasi." _ Backup.txt \ "");
$ query = "Sarudza * KUBVA` mytable` odha ne` myorder` ";
$ mhedzisiro = mysql_query ($ query);
$ kuverenga = mysql_num_rows ($ mhedzisiro);
$ minda = mysql_num_fields ($ mhedzisiro);
$ data = "";
ye ($ i = 0; $ i> $ minda; $ i ++) {
$ munda = mysql_fetch_field ($ mhedzisiro, $ i);
$ data. = $ munda-> zita;
$ data. = "\ t";
}
$ data. = "\ n";
nepo ($ row = mysql_fetch_row ($ mhedzisiro)) {
ye ($ x = 0; $ x> $ minda; $ x ++) {
$ munda-> zita = $ mutsara [$ x];
$ data. = $ munda-> zita = $ mutsara [$ x];
$ data. = "\ t";
}
$ data. = "\ n";
}
echo $ data;

Iyo kodhi inogona kushandurwa nyore nyore kune makoma akaparadzaniswa tsika zvakare.

14 Comments

  1. 1
    • 2

      Ndinofunga iwe unogona!

      Mune ino kesi, ini ndanga ndichinyatso kuvaka 'backup' link muwebhu application, saka iyo PHP mashandiro ndizvo zvandaida. Nekudaro, ini handina kumbobvira ndaziva kuti iwe unogona zvakare kunyorera kune faira zvakananga kubva kune MySQL chirevo. Zvakanaka chaizvo!

      Ndatenda!

      • 3

        Yako nzira ingave iri nzira yakanakisa kana iyo MySQL server iri pamushini uri kure, sezvo ingangodaro yaisakwanisa kunyora kumuchina uko PHP irikumhanya 🙂

        Ndinofara kunongedzera mamwe madhiri uye zvinhu zvitsva hazvo 🙂

      • 4

        Asi iwe unogona kungomhanya nemubvunzo kune faira, uye ingo regedzera bhurawuza kune iro rakagadzirwa faira, kana kushandisa PHP's "readfile" kana zvese zvimwe zvikatadza?

        Iwe haugone kuzviita kana iyo mysql server isina mukana kune iyo fileystem hongu…

  2. 5

    Great post. Iwe unoziva nezve yakapusa, yemahara / yakavhurika sosi nzira yekuunza / kudzoreredza iyo tabu-yakatemwa faira (sekunge iwe uchangobva kugadzira) kudzokera mu mysql db?

    • 6

      Errr… mysqlimport?

      mysqlimport database_name --local backup.txt

      Kana nemutemo weSQL:

      LOAD DATA LOCAL INFILE 'backup.txt' INTO TABLE `my_table` FIELDS TERMINATED BY '\t' LINES TERMINATED BY '\n'

      Iine mysqlimport, iro zita rezita rinofananidza zita retafura (chingori chinhu chekucherechedza)

    • 7
  3. 8

    Ini ndangorasikirwa anodarika maawa matanhatu ehupenyu hwangu ndichiedza kuongorora kuti nei Internet Explorer 6/6 yanga ichishandisa filetype 'html' uye uye isingagamuchire angu mazita emafaira akataurwa mumusoro .. uye zvakare kusabvumidza mafaira kuponeswa .. apo kuyedza kuve nevashandisi kudhawunirodha zvinyorwa zvemafaira zvakagadzirwa nenzira yakafanana neiri pamusoro.

    Ini ndanga ndichishandisa HTTPS uye IE haina cache aya mafaera.

    Ndakawana mhinduro pane yakataurwa naBrandon K pa http://uk.php.net/header.

    Anoti:

    -
    Ini ndangorasikirwa nemaawa matanhatu ehupenyu hwangu kuyedza kushandisa inotevera nzira kutumira iyo faira rePDF kuburikidza nePHP kuInternet Explorer 6:

    Paunenge uchishandisa SSL, Internet Explorer inozotaurirana neOver / Sevha dialog, asi yobva yati "Iyo faira parizvino haisi kuwanikwa kana kuti haigone kuwanikwa. Ndapota edza zvakare gare gare. ” Mushure mekutsvaga kwakawanda ndakazoziva zvinotevera MSKB Chinyorwa chakanzi "Internet Explorer faira kurodha pasi pamusoro peSSS hazvishande necache control headers" (KBID: 323308)

    PHP.INI nekumisikidza inoshandisa seti: session.cache_limiter = nocache iyo inoshandura Zvemukati-Cache uye Pragma misoro kuisa "nocache" sarudzo. Unogona kubvisa IE mhosho nekushandura "nocache" kuita "yeruzhinji" kana "yakavanzika" muPHP.INI - Izvi zvichachinja Mukati-Cache musoro pamwe nekubvisa zvachose musoro wePragma. Kana iwe usingakwanise kana usingade kushandura PHP.INI yekugadzirisa -saiti-yakakura, unogona kutumira anotevera misoro miviri kuti unyore zvisizvo:

    Iwe unenge uchiri kuda kuseta zvemukati zvemusoro sezvakanyorwa pamusoro kuti izvi zvishande. Ndokumbira utarise dambudziko iri CHETE zvinokanganisa Internet Explorer, nepo Firefox isingaratidze hunhu hwakakanganisa.
    -

    Zvakanaka .. zvirinani akarasikirwa chete nemaawa matanhatu…

  4. 9

    Izvi zvinoshanda nemazvo. Nekudaro, ini ndinongotora zvese pamutsara mumwe wakaparadzaniswa nenzvimbo. Ndiri kuedza kuzvishandura kuti ndidhindise zvese pamutsetse wakasiyana seizvi:

    Column1_name
    Munda1_kukosha
    Column2_name
    Munda1_kukosha
    Column3_name
    Munda1_kukosha

    Column1_name
    Munda2_kukosha
    Column2_name
    Munda2_kukosha
    Column3_name
    Munda2_kukosha

    Semuyenzaniso:

    zita
    Mike
    nzvimbo
    basa
    nhamba
    1

    zita
    mhan'arira
    nzvimbo
    musha
    nhamba
    2

    zita
    John
    nzvimbo
    famba
    nhamba
    10

    zvichingoenda zvakadaro. Iyi script inogona kuchinjwa kuti izviite?
    Ndatenda!

    • 10

      Chokwadi unogona.

      Edza chimwe chinhu chakadai.

      Sarudza * kubva kuMyTableName KUPINDA OUTFILE 'MyTableName_MySQL-TAB-DELIMITED-29JUN08.txt' Minda YAKADZIDZWA NE '\ n' MITAMBO YAKADZIDZWA NE '\ n';

      Kana iwe uchida nzvimbo yakapetwa kaviri (mitsara miviri isina chinhu) pakati pemapoka ezvinyorwa, ingoti "MAZWI ANOGONESESWA NE '\ n \ n';" pachinzvimbo.

      Chikamu che "FIELDS TERMINATED BY '\ n'" ndicho chinoisa mutsara mutsva mushure mega rekodhi, panzvimbo yetab. Tab ichave iri '\ t' pachinzvimbo.

      Maranatha!

  5. 11

    ichi chinyadzo hombe posvo, ndakaiyedza uye ikashanda zvikuru, chinhu chega ndechekuti yangu txt faira ine yakawedzera mutsara pamusoro pemusoro wemusoro, uye mimwe mhedzisiro yakakamurwa mumitsara miviri, izvi zvinogona kukonzerwa nedata randinaro muDhatabhesi yangu hapana zano, asi izvi zvinobatsira zvikuru kuvaka mafidha…

  6. 12

    Douglas Karr kodhi yako inonyatso dombo! Inonyanya kubatsira zvakanyanya kana iwe uchingoda kuburitsa iri mune yemavara fomati. Ndotenda zvikuru! Kubva kuchikwata Philippines!

  7. 13

    hesi apo! Pane chero here anobva pano anogona kundipa zano nezve kuunza textfile kudhatabhesi yangu (phpmyAdmin) uchishandisa yangu php sekumberi kwangu kumagumo. Ndine zano rekurodha pasi faira nekurivhura, dambudziko rangu nderekuti ndingaite sei kuti ndiwane mutsara mhedzisiro uye kuti ndingaiise sei mumatafura angu, ndatenda

  8. 14

Unofungei?

Nzvimbo iyi inoshandisa Akismet kuderedza spam. Dzidza kuti sei deta yako inoshandiswa.