单个过滤器,用于数据表中的额外位置

时间:2017-05-26 06:39:38

标签: php filter where-clause jointable datatables-1.10

关注link1link2。使用https://github.com/emran/ssp回答了这个问题。但我在下面的查询中遇到问题:

$joinQuery = "FROM `monitor` AS `a` JOIN `sym_category` AS `b` JOIN `model_cat` AS `c`";
$joinQuery.= "ON (`b`.`id_sym` = `a`.`id_sym`) AND (`c`.`id_mod` = `a`.`id_mod`)";
$extraWhere= "`a`.`id_car` LIKE 'MKT%' OR `a`.`id_car` LIKE 'RK%' OR `a`.`id_car` LIKE 'CC%'";

echo json_encode(
        SSP::simple( $_GET, $sql_details, $table, $primaryKey, $columns, $joinQuery, $extraWhere )
);

ssp.class.join.php:

static function simple($request,$sql_details,$table,$primaryKey,$columns,$joinQuery = NULL,$extraWhere = '',$groupBy = '')
    {
        $bindings = array();
        $db = SSP::sql_connect( $sql_details );

        // Build the SQL query string from the request
        $limit = SSP::limit( $request, $columns );
        $order = SSP::order( $request, $columns, $joinQuery );
        $where = SSP::filter( $request, $columns, $bindings, $joinQuery );

        // IF Extra where set then set and prepare query
        if($extraWhere){
            $extraWhere = ($where) ? ' AND '.$extraWhere : ' WHERE '.$extraWhere;
}
        $groupBy = ($groupBy) ? ' GROUP BY '.$groupBy .' ' : '';

        // Main query to actually get the data
        if($joinQuery){
            $col = SSP::pluck($columns, 'db', $joinQuery);
            $query =  "SELECT SQL_CALC_FOUND_ROWS ".implode(", ", $col)."
             $joinQuery
             $where
             $extraWhere
             $groupBy
             $order
             $limit";
        }else{
            $query =  "SELECT SQL_CALC_FOUND_ROWS `".implode("`, `", SSP::pluck($columns, 'db'))."`
             FROM `$table`
             $where
             $extraWhere
             $groupBy
             $order
             $limit";
        }

我尝试放置一些$extraWhere后,单列过滤器无法正常工作,但过滤的数据可能会出现(status 200 OK)

我试图删除:

$extraWhere= "/*`a`.`id_car` LIKE 'MKT%' OR */`a`.`id_car` LIKE 'RK%' OR `a`.`id_car` LIKE 'CC%'";

单列过滤器正在运行,但是当我在where子句中添加过滤器MKT%时它为什么不起作用?

0 个答案:

没有答案