我在 Datatable 搜索 ssp.class.php 中遇到了同样的问题,我通过转换为 UTF8 来解决,例如:
CONVERT(`user_datetime` USING utf8)
在 ssp.class.php 中修复:
$globalSearch[] = "CONVERT(`".$column['db']."` USING utf8) LIKE ".$binding;
我的最终代码是:
static function filter ( $request, $columns, &$bindings )
{
$globalSearch = array();
$columnSearch = array();
$dtColumns = self::pluck( $columns, 'dt' );
if ( isset($request['search']) && $request['search']['value'] != '' ) {
$str = $request['search']['value'];
for ( $i=0, $ien=count($request['columns']) ; $i<$ien ; $i++ ) {
$requestColumn = $request['columns'][$i];
$columnIdx = array_search( $requestColumn['data'], $dtColumns );
$column = $columns[ $columnIdx ];
if ( $requestColumn['searchable'] == 'true' ) {
$binding = self::bind( $bindings, '%'.$str.'%', PDO::PARAM_STR );
$globalSearch[] = "CONVERT(`".$column['db']."` USING utf8) LIKE ".$binding;
}
}
}