是否有工具或任何快速方法可以自动从我的PHP代码中提取DB表?
我最近开始重新设计一个大约7年前创建的PHP-MYSQL项目。我只有PHP和HTML代码,没有MySQL数据库或任何显示数据库结构的文档。
是否有任何工具可以帮助我使用PHP文件提取数据库的表?在PHP文件中,我插入查询并选择查询并更新。
我认为一种工具(这样的爬网)将我的PHP文件作为输入,并创建一些SQL创建表查询作为输出。
I recently started to re-engineer a PHP-mysql project which was created about 7 years ago. I have only php and html codes and no mysql database or any document which shows the database structures.
Is there any tool which help me extract the tables of my database using php files? in the php files i have insert queries and select queries and also update.
I think of a tool (such a crawler) which takes my php files as input and create some sql create table queries as output.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
恐怕没有这样的工具。无法保证您的PHP代码甚至可以引用每个表或每一列。您可能会看到这样的代码:
列名是什么?他们的数据类型是什么?第一列是整数,还是仅将数字放入字符串定界符中的开发人员的习惯?第四列引用的默认值是多少?自动化工具如何通过扫描此代码来推断这些内容?
触发器,约束和索引等许多详细信息根本没有通过PHP代码来引用,但是它们对于使应用程序工作必不可少。
如果数据库具有任何存储过程,则PHP代码将在过程中没有任何逻辑知识。
查询定义中的查询也存在相同的问题。
逆向工程这个项目将是一项耗时的法医任务,还有很多猜测。
它确实说明了将当前的架构转储与项目的源代码中加入的重要性。
I'm afraid there is no such tool. There's no guarantee that your PHP code even makes reference to every table or every column. You might see code like this:
What are the column names? What are their data types? Is the first column an integer, or is it just the developer's habit to put numbers inside string delimiters? What's the default value referenced by the fourth column? How could an automated tool infer these things by scanning this code?
Many details such as triggers, constraints, and indexes, are not referenced at all by PHP code, but they're necessary to make the application work.
If the database has any stored procedures, the PHP code wouldn't have any knowledge of the logic inside the procedure.
The same problem exists for the query in VIEW definitions.
Reverse engineering this project is going to be a time-consuming forensic task, plus a lot of guesswork.
It really illustrates the importance of including the current schema dump with the source code of a project.