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 kodhi inoguma 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 waigona!

      Muchiitiko ichi, ini ndanga ndichigadzira 'backup' link muwebhu application, saka iyo PHP mashandiro ndiwo andaida. Nekudaro, ini handina kumboziva kuti iwe unogona zvakare kunyora kune faira zvakananga kubva kuMySQL statement. Very cool!

      Ndatenda!

      • 3

        Nzira yako ingave nzira yakanakisa kana sevha yeMySQL iri pamushini uri kure, sezvo ingangotadza kunyora pamushini uri kushanda PHP 🙂

        Ndinofara kuratidza mamwe mafambiro uye zvinhu zvitsva kunyangwe 🙂

      • 4

        Asi iwe unogona kungomhanyisa mubvunzo kune faira, uye wongotungamira bhurawuza kufaira rakagadzirwa, kana kushandisa PHP's "readfile" kana zvese zvikatadza?

        Iwe haugone kuzviita kana iyo mysql server isingakwanise kuwana iyo faira system hongu…

  2. 5

    Great post. Iwe unoziva nezve nyore, yemahara / yakavhurika sosi nzira yekupinza / kudzoreredza tebhu-yakatemerwa faira (senge iwe uchangobva kugadzira) kudzoka mumysql db?

    • 6

      Errr… mysqlimport?

      mysqlimport database_name --local backup.txt

      Kana nemurairo weSQL:

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

      Ne mysqlimport, iro zita refaira rinofanira kuenderana nezita retafura (chimwe chinhu chekutarisira)

    • 7
  3. 8

    Ndangorasikirwa nemaawa anopfuura matanhatu ehupenyu hwangu ndichiedza kutsvaga kuti sei Internet Explorer 6/6 yaishandisa filetype 'html' uye uye kusagamuchira mazita angu efaira akatsanangurwa mumusoro.. uye kusabvumira mafaira kuti achengetedzwe.. kuyedza kuita kuti vashandisi vatore mameseji mafaira akagadzirwa nenzira yakafanana nepamusoro.

    Ini ndanga ndichishandisa HTTPS uye IE haina cache aya mafaera.

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

    Anoti:

    -
    Ndangorasikirwa nemaawa matanhatu ehupenyu hwangu ndichiedza kushandisa nzira inotevera kutumira faira rePDF kuburikidza nePHP kuInternet Explorer 6:

    Paunenge uchishandisa SSL, Internet Explorer ichakurumidza neiyo Vhura / Sevha dialog, asi yobva yati "Faira harisi kuwanikwa kana kuti hariwanikwe. Ndapota edza zvakare gare gare." Mushure mekutsvaga zvakanyanya ndakaziva zvinotevera MSKB Chinyorwa chakanzi "Internet Explorer faira kurodha pamusoro peSSL haishande necache control headers" (KBID: 323308)

    PHP.INI nekusarudzika inoshandisa kuseta: session.cache_limiter = nocache inoshandura Content-Cache nePragma misoro kuti ibatanidze “nocache” sarudzo. Unogona kubvisa IE kukanganisa nekushandura "nocache" kuita "public" kana "private" muPHP.INI - Izvi zvinoshandura Content-Cache musoro pamwe nekubvisa zvachose Pragma musoro. Kana iwe usingakwanise kana usiri kuda kushandura PHP.INI yesaiti-yakafara gadziriso, unogona kutumira iyo inotevera misoro miviri kuti inyore pamusoro defaults:

    Iwe uchazofanira kuseta iyo yemukati misoro sezvakanyorwa pamusoro kuti izvi zvishande. Ndokumbira utarise dambudziko iri CHETE rinokonzeresa Internet Explorer, nepo Firefox isingaratidzi maitiro akakanganisika.
    -

    Zvakanaka.. angorasikirwa ne6 hours chete...

  4. 9

    Izvi zvinoshanda zvakanaka. Nekudaro, ini ndinongowana zvese pamutsetse mumwe wakaparadzaniswa nenzvimbo. Ndiri kuedza kuigadzirisa kuti iprinte zvese pamutsetse wakasiyana seuyu:

    Column1_name
    Munda1_value
    Column2_name
    Munda1_value
    Column3_name
    Munda1_value

    Column1_name
    Munda2_value
    Column2_name
    Munda2_value
    Column3_name
    Munda2_value

    Semuyenzaniso:

    zita
    Mike
    nzvimbo
    basa
    nhamba
    1

    zita
    mhan'arira
    nzvimbo
    musha
    nhamba
    2

    zita
    John
    nzvimbo
    famba
    nhamba
    10

    zvichingoenda zvakadaro. Ichi chinyorwa chinogona kugadziridzwa kuti chizviite here?
    Ndatenda!

    • 10

      Chokwadi unogona.

      Edza chimwe chinhu chakadai.

      SARUDZA * kubva kuMyTableName KUPINDA OUTFILE 'MyTableName_MySQL-TAB-DELIMITED-29JUN08.txt' MINDA AKAGUMISWA NE'\n' MITARA AKAGUMISWA NE '\n';

      Kana iwe uchida nzvimbo yakapetwa kaviri (mitsetse miviri isina chinhu) pakati pemapoka erekodhi, ingoti “MITSARA AKADZIDZWA NE '\n\n'; pachinzvimbo.

      Iyo "FIELDS TERMINATED BY '\n'" chikamu ndicho chinoisa mutsara mutsva mushure merekodhi yega yega, pachinzvimbo chetabhu. Tabhu ingave '\t' pachinzvimbo.

      Maranatha!

  5. 11

    ichi chinonyangadza chitubu chikuru, ndakachiyedza uye ndikashanda zvakanaka, chinhu chega ndechekuti faira rangu retxt rine mutsara wekuwedzera pamusoro pemazita emusoro, uye mamwe mhedzisiro akapatsanurwa mumitsara miviri, izvi zvinogona kukonzeresa nedata randinaro. muDatabhesi yangu hapana zano, asi iyi inobatsira zvikuru kuvaka mafeed...

  6. 12

    Douglas Karr kodhi yako inoshamisa! Inobatsira zvakanyanya kana iwe uchingoda chinobuda chiri mune textfile fomati. Ndotenda zvikuru! Kubva kuchikwata chePhilippines!

  7. 13

    hey apo! Pane chero munhu anobva pano anogona kundipa zano nezve kupinza textfile kune yangu dhatabhesi(phpmyAdmin) ndichishandisa php yangu sekumberi kwangu. Ndine pfungwa yekudhawunirodha faira nekurivhura, dambudziko rangu nderekuti ndingawane sei mutsara wemhedzisiro uye nekuiisa sei mumatafura angu, ndatenda

  8. 14

Unofungei?

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