且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

将 blob 行从 MySQL 转储到文件

更新时间:2023-10-07 08:55:28

PHP 中的一些快速方法:

Something quick in PHP:

<?php
$connection = mysql_connect("mysqlserver.example.com", "username", "password");
mysql_select_db("dbname");
$sql = "SELECT `blob_column`, `id` FROM `mytable`";
$result = mysql_query($sql);
while ($row = mysql_fetch_assoc($result)){
    file_put_contents("file" + $row["id"] + ".dat", $row["blob_column"]);
}
mysql_close($connection);

您可能可以使用任何必须访问 MySQL 的方法来做一些类似的事情,但是 AFAIK,没有办法使用纯 SQL 来做到这一点.

You could probably do something simular with whatever method you have to access MySQL, but AFAIK, there's no way to do it with pure SQL.