【问题标题】:IgnitedTables | Filtering on Group Concat gives Error点燃表 |对组 Concat 进行过滤会产生错误
【发布时间】:2015-02-05 18:49:18
【问题描述】:

我在 Codeigniter 中为 Datatables 使用 Ignite Tables, 我面临的问题是 ignited Tables 对 Group Concat 没有适当的支持,因为我正在使用 Group Concat,我收到 MySQL 错误。

Error Number: 1111

Invalid use of group function

SELECT `E`.`employee_id`, `E`.`full_name`, `MLD`.`designation_name`, GROUP_CONCAT(DISTINCT MLP.project_title) AS Projects, GROUP_CONCAT(DISTINCT MLST.skill_name) AS EmployeeSkills FROM (`emp_skills` ES) INNER JOIN `employee` E ON `E`.`employee_id`= `ES`.`employee_id` INNER JOIN `ml_skill_type` MLST ON `MLST`.`skill_type_id` = `ES`.`ml_skill_type_id` INNER JOIN `employment` ET ON `ET`.`employee_id` = `E`.`employee_id` INNER JOIN `position_management` PM ON `PM`.`employement_id`=`ET`.`employment_id` AND PM.current=1 INNER JOIN `ml_designations` MLD ON `MLD`.`ml_designation_id`=`PM`.`ml_designation_id` LEFT JOIN `assign_job` AJ ON `AJ`.`employee_id` = `E`.`employee_id` LEFT JOIN `ml_projects` MLP ON `MLP`.`project_id` = `AJ`.`project_id` WHERE (E.full_name LIKE '%s%' OR MLD.designation_name LIKE '%s%' OR GROUP_CONCAT(DISTINCT MLP.project_title) LIKE '%s%' OR GROUP_CONCAT(DISTINCT MLST.skill_name) LIKE '%s%' ) GROUP BY `E`.`employee_id` LIMIT 25

Filename: C:\xampp\htdocs\projects\HR\system\database\DB_driver.php

Line Number: 330

我正在使用 0.7 版的 ignited 表,但仍然在 2.0 版中,我看不到对组 concat 的任何支持,我会更新到 2.0 版,但当我尝试从 0.7 版更新到 2.0 的 ignited 时出现错误表格。

我使用的 DataTables 库: https://github.com/pakistanihaider/HouseRentSystem/blob/master/application/libraries/Datatables.php

我可以在我的库中对 Group Concat 进行任何修复以修复数据表中的过滤吗?


github上有一个解决方案,因为这个问题之前已经提出过。但它不是永久解决方案,好像使用此解决方案然后过滤器仅适用于 group_concats 如果存在于表中并且其他简单表未被过滤。

但是如果没有组 concat 那就没问题了..

现在如何同时对 group_concat 列和简单列进行过滤。?


刚刚发现如果使用 Group_Concat.. ,总结果和分页存在问题 :( 而且我必须使用数据表,因为整个项目都是使用数据表构建的..

有谁熟悉 ignited 表库? https://github.com/IgnitedDatatables/Ignited-Datatables/issues/76

【问题讨论】:

  • 您解决了这个问题吗?我也遇到了这个问题?

标签: mysql codeigniter datatables


【解决方案1】:

只需将带有GROUP_CONCAT 的列不包括在可搜索范围内即可推翻它。

$(document).ready(function() {
  $('#your-table').dataTable({
    "columnDefs": [{
      "bSearchable": false,
      "render": function(data, type, row) {
        //if you had any rendering
        return data;
      },
      "targets": 3 //column with the group concat
    }]
  });
});

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-09-06
    • 2019-06-15
    • 2020-12-03
    • 1970-01-01
    • 1970-01-01
    • 2014-07-23
    相关资源
    最近更新 更多