English 中文(简体)
MySQL向CSV出口,提供博彩田
原标题:MySQL export to CSV with blob field

我曾向BLOB出口过一个使用php的剪辑。 显然,博彩不是正常的领域,而是有时使用。 但在此我需要的是,我需要这一文字才能工作,用速成表格,每行出口。 布洛布正在对此进行改观。 我曾试图将64-encode the blob作为基础,但我认为,将不正确地出口该书。

这就是我迄今为止所做的事情:

function exportcsv($tables) {
    foreach ($tables as $k => $v) {
        $fh = fopen( sql/ .$v. .csv ,  w );
        $sql = mysql_query("SELECT * FROM $v");
        while ($row = mysql_fetch_row($sql)) {
            $line = array();
            foreach ($row as $key => $v) {
                $line[] = base64_encode($v);
            }
            fputcsv($fh, $line, chr(9)); //tab delimiting
        }
        fclose($fh);
    }
}

希望得到任何帮助。

EDIT: Here is an image of the blob export WITHOUT base64_encode(). https://www.strongspace.com/shared/crypok1lxb

So, will base64 protect the format of blob when the need to reimport arises?

最佳回答

第64号基地编码的目的是使双轨数据通过运输层保持下去,这些运输层并非8倍的清洁,因此,你正沿着正确的轨道进行。

你们真正需要担心的是这种投入作用。 你们需要检查哪些危险物品?

  1. Tabs, because this is your delimiter
  2. New line characters, because it seems you are also parsing by line

http://stackoverflow.com/questions/3092019/can-a-base64-encoded-string-contain-whitespace> 这一链接,第64号基地仅覆盖A-Z、a-z、0-9、+和/,这意味着你的安全,你所展示的新形象可能是一种手法,从你正在使用的民主选举学会的文字总结来看。 现在,你们必须记住的是,当你想把这一数据输入非银时,我们不会指望仅仅使用我的原状或我的q子;而要把它pipe在一边。 您将不得不另设一个使用基64_decode的实验室功能,使数据回到原来的状态。

You should also be aware that you are currently encoding all of the fields, not just the blob data. Base64 encoding takes up some ~33% more space as an FYI so you may want to define your tables with some bit indicating if the field is a blod and you want to enable B64 encoding on it.

问题回答

暂无回答




相关问题
SQL SubQuery getting particular column

I noticed that there were some threads with similar questions, and I did look through them but did not really get a convincing answer. Here s my question: The subquery below returns a Table with 3 ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

php return a specific row from query

Is it possible in php to return a specific row of data from a mysql query? None of the fetch statements that I ve found return a 2 dimensional array to access specific rows. I want to be able to ...

Character Encodings in PHP and MySQL

Our website was developed with a meta tag set to... <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> This works fine for M-dashes and special quotes, etc. However, I ...

Pagination Strategies for Complex (slow) Datasets

What are some of the strategies being used for pagination of data sets that involve complex queries? count(*) takes ~1.5 sec so we don t want to hit the DB for every page view. Currently there are ~...

Averaging a total in mySQL

My table looks like person_id | car_id | miles ------------------------------ 1 | 1 | 100 1 | 2 | 200 2 | 3 | 1000 2 | 4 | 500 I need to ...

热门标签