如何使用 DataTables jQuery 插件从 BD 读取 blob?

How read blob from BD with the DataTables jQuery plugin?

我尝试使用 DataTables 服务器端处理读取 blob 字段,但我做不到。我想我应该转换为 base64,但我不知道它是如何工作的。

$columns = array(
     array('db' =>'ID','dt'=>0),
     array('db'=>'LOGIN','dt'=>1),
     array('db'=>'IMG','dt'=>2)
);
$sql_details = array(
    'user' => 'x',
    'pass' => 'x',
    'db'   => 'x',
    'host' => 'x',
    'charset' => 'utf8'
);
require( 'scripts/ssp.class.php' );
echo json_encode(
    SSP::simple( $_POST, $sql_details, $table, $primaryKey, $columns)
);

我找到了解决方案。格式化程序允许编写一个函数。

$columns = array(
    array('db' =>'ID','dt'=>0),
    array('db'=>'LOGIN','dt'=>1),
    array(
       'db' => 'IMG',
       'dt' => 2,
       'formatter' => function($d, $row) {
        return base64_encode($d);
    })
);