问题描述
我正在寻找在PHP中解析INSERT和UPDATE MySQL SQL查询,以确定从原始数据中进行哪些更改.现在,创建起来非常容易,但是我想看看PHP中是否有任何现有的库可以做到这一点.
I am looking to parse INSERT and UPDATE MySQL SQL queries in PHP to determine what changes where made from what original data. Now this would be pretty easy to create, but I want to see if there are any existing libraries in PHP to do this.
基本上我所拥有的是一张表,上面已在数据库上运行了所有以上查询.我已经分离出表名和查询类型.我希望基于此数据创建完整的更改日志以供用户查看,因此我需要获取原始INSERT的值,然后在每个UPDATE中进行更改.最后,我需要字段名称和新值以及记录ID.我将进行其余的检查/美化工作,包括将列名更改为易于理解的字段,以及是否未真正更改字段值.
Basically what I have is a table with all of the above queries that have been run on a database. I have already separated out the table name and type of query. I am looking to create a full change log for user viewing based on this data, so I need to get the values of the original INSERT and then changes that are made in each UPDATE. In the end I need field name and new value and with the record id(s). I'll do the rest of the checking/beautifying, including the column name to human readable and if a field value hasn't actually changed.
此刻,我可能不需要执行多个表UPDATE,但这很有用.
At the moment, I probably don't need to do multiple table UPDATE's, but it would be useful.
有哪些库可以做到这一点?
What libraries are there to do this?
推荐答案
http://pear.php .net/package/SQL_Parser
http://sourceforge.net/projects/txtsql
http://code.google.com/p/php-sql-parser
对于Perl来说,种类更多
For Perl there's more variety
这篇关于PHP MySQL SQL解析器(INSERT和UPDATE)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!