Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/287.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/67.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 将数据透视表更新为数据库_Php_Mysql_Database_Wordpress_Datatables - Fatal编程技术网

Php 将数据透视表更新为数据库

Php 将数据透视表更新为数据库,php,mysql,database,wordpress,datatables,Php,Mysql,Database,Wordpress,Datatables,我有一个来自MySQL查询的数据透视表,该查询源自: +------------+------------+-----------------+------------------+------------+-----+ |submit_time |form_name |field_name | field_value |file_order |file | +------------+------------+-----------------+---------

我有一个来自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
该插件允许用户在前端编辑表格。当我试图通过前端表编辑表中的任何值时,出现了一个错误提示,并且没有更新值

返回的错误是字段列表中的
错误未知列“Requestor”
。我猜DB不会识别列标题,因为它们已经被旋转了


我正在寻找解决这个问题的方法。任何帮助都将不胜感激。

谁或什么人正在使用您(功能正常的)pivot查询的输出?如果它不期望一个名为
请求者
的列,那么它实际期望的是什么?@TimBiegeleisen我认为它期望的是'field\u name',当然你可以将
请求者
别名为
field\u name
,但你不能对查询中的每一列都这样做。@TimBiegeleisen完全正确!当我将
请求者
和其余的更改为
字段名
时,得到的表与最初的表类似。Bummer…@TimBiegeleisen如果我将这个查询的表保存为一个新的数据库,然后让wpDataTables在新的数据库上读取/udate,你认为这可行吗?