UPDATE将表转移到DB

时间:2017-09-19 05:29:10

标签: php mysql database wordpress datatables

我有来自MySQL查询的数据透视表,该表源自:

+------------+------------+-----------------+------------------+------------+-----+
|submit_time |form_name   |field_name       | field_value      |file_order  |file | 
+------------+------------+-----------------+------------------+------------+-----+
|15052703120 |Submissions |your-name        | Leonard Chia     |9999        |file | 
+------------+------------+-----------------+------------------+------------+-----+
|15052703120 |Submissions |your-email       | leonard@mail     |8           |file | 
+------------+------------+-----------------+------------------+------------+-----+
|15052703120 |Submissions |status           | Pending Start    |9           |file | 
+------------+------------+-----------------+------------------+------------+-----+
|15052703120 |Submissions |location         | DD1 Classroom    |7           |file | 
+------------+------------+-----------------+------------------+------------+-----+

到此:

+-------------+-------------+-----+--------------+---------------+
| Requestor   | Email       |ETC. |Location      | Status        |
+-------------+-------------+-----+--------------+---------------+
|Leonard Chia | leonard@mail|ETC. |DD1 Classroom | Pending Start |
+-------------+-------------+-----+--------------+---------------+
|Sng Yeekia   | yeekias@mail|ETC. |DD2 Classroom | Pending Spare |
+-------------+-------------+-----+--------------+---------------+
|Gabriel Lee  | gabriel@mail|ETC. |SL1 Classroom | Completed     |
+-------------+-------------+-----+--------------+---------------+

该表是使用wpDataTables插件实现的,该插件为我的网页上显示的表提供了一个短代码。用于提取数据的查询是这样的:

SELECT
    submit_time,
    MAX(IF(field_name = 'your-name',     field_value, NULL)) AS Requestor,
    MAX(IF(field_name = 'campus',        field_value, NULL)) AS Campus,
    MAX(IF(field_name = 'location',      field_value, NULL)) AS `Defect Location`,
    MAX(IF(field_name = 'your-message',  field_value, NULL)) AS `Defect Description`,
    MAX(IF(field_name = 'menu-priority', field_value, NULL)) AS Priority,
    MAX(IF(field_name = 'work-done',     field_value, NULL)) AS `Action Taken`,
    MAX(IF(field_name = 'assigned-to',   field_value, NULL)) AS `Assigned To`,
    MAX(IF(field_name = 'category',      field_value, NULL)) AS Category,
    MAX(IF(field_name = 'file-photo',    field_value, NULL)) AS Photo
    MAX(IF(field_name = 'status',        field_value, NULL)) AS Status
FROM
    wpc5_cf7dbplugin_submits
GROUP BY
    submit_time

该插件允许用户编辑前端的表格。当我尝试通过前端表编辑表中的任何值时出现问题,提示错误并且值不会更新。

返回的错误是ERROR Unknown column 'Requestor' from the field_list。我猜这个数据库因为它们已被转动而无法识别列标题。

我正在寻找有关如何解决此问题的想法或解决方法。任何帮助将不胜感激。

0 个答案:

没有答案