doulongsha5478 2015-10-20 20:22
浏览 53
已采纳

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

I try to read a blob field with DataTables Server-side processing but I can't. I suppose than I should transform to base64, but I don't know how it works.

$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)
);
  • 写回答

1条回答 默认 最新

  • dourang6423 2015-10-21 08:00
    关注

    I found the solution. Formatter allows write a function.

    $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);
        })
    );
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?