XML 是否可以像 MySQL 一样用于在 PHP 中存储、修改和检索数据?管理通用存储的数据(例如 CRUD、CMS)

发布于 2024-12-05 13:40:07 字数 1024 浏览 0 评论 0原文

这是一个又长又老的问题,但没有抓住重点。我基本上想了解涉及平面文件的实践以及它们可以使用的范围,作为 SQL 的替代品,主要是在多用户功能方面。

当时,我想复制 SQL带有平面文件的表格编辑器界面,允许协作编辑。基本上就像一个多用户 Excel,具有自动数据输入界面和交互式可排序表格。 我还想为服务器构建一个 CMS 索引页面,它解析文本文件以构建动态网页,从而轻松更新/管理。

我已经开始学习 MySQL 和 XML。对于动态数据存储,我更喜欢 XML 而不是 MySQL,因为它不需要服务器并且可以在文本编辑器中进行编辑,但我不确定它们是否可以用于类似的事情。

(我知道 MySQL 和 XML 是两个完全不同的东西,但我正在考虑数据存储方面的问题。)

过去,我手动将内容列表存储在 *.txt 文件中(跟踪事物),有时每行有多个字段,例如表格或包含相关数据的行。 HTML 表格对此很有帮助,但如果能够直接在页面中进行编辑而不需要文本编辑器,并且在某些情况下,允许多人(协作编辑)同时编辑不同的部分,那就更好了。

(我想使用 PHP 创建可以执行此操作的脚本 - 允许在浏览器中编辑文件,包括协作。我想学习一般的数据操作方法。)

所以基本上,我想创建一个我想要以内容管理系统的形式显示的任何脚本和文档的索引。我希望页面以某种方式模块化。某些模块是带有表格数据的 CRUD(创建、读取、更新、删除),另一个模块可能是从 PHP 脚本派生的类似 Pastebin 的文本转储,某种文章- 类似 wiki 的链接文章、单篇文章或博客文章的发布系统。

不管怎样,我已经制作了解析 XML 文件的脚本,并且我喜欢将内容与表示分离的想法,但我不知道如何/是否可以将 XML 合并到 CMS(或任何动态可编辑的情况)中,就像大多数人一样流行的使用MySQL。这仅供个人使用,不适用于某些大型站点,如果它简单且可移植就更好了,只需要 Web 服务器。我只喜欢将 MySQL 作为最后的手段,因为我不喜欢每次切换服务器时都必须设置 MySQL,或者遇到 MySQL 连接错误。

我应该做什么/有什么建议吗?

This is a long and old question that doesn't get to the point. I basically wanted to know practices involving flat files and the extent they could be used, as a replacement for SQL, mostly in terms of multi-user capability.

At the time, I was wanting to replicate a SQL table editor interface with flat files, allowing collaborative editing. Basically like a multiuser Excel, with an automated data-entry interface, and interactive sortable tables.
I also wanted to build a CMS index page for a server, which parsed text files in order to construct a dynamic webpage, which allowed for easy updating/managing.

I've been beginning to learn MySQL, and XML. For dynamic data storage, I prefer XML over MySQL because it doesn't require a server and can be edited within a text-editor, but I'm unsure whether they can be used for similar things.

(I know that MySQL and XML are two completely different things, but I'm looking at this in regards to data storage.)

In the past I've manually stored lists of stuff in *.txt files (to keep track of things), sometimes with multiple fields per-row kinda thing, like a table, or lines with related data. HTML tables are good for this, but it would be even nicer to be able to edit directly in the page without the need for a text editor, and in certain situations, allow multiple persons (collaborative editing) to edit different sections at the same time.

(I want to use PHP to create scripts that can do this - allow editing of files in browser, including collaborative. I want to learn data manipulation methods in general.)

So basically, I want to create an index for whatever scripts and documents I'd want to display, in the form of a Content Management System. I'd want pages to be modular somehow.. Some modules would be a CRUD (create, read, update, delete) with tabular data, another module could be a pastebin-like text dump derived from a PHP script, some sort of article-publishing system for wiki-like linked articles, single articles or blog posts.

Anyway, I've made scripts that parse XML files, and I like the idea of separating content from presentation, but I don't know how/if XML could be incorporated into a CMS (or any dynamically-editable situation), as most popular ones use MySQL. This is only for personal use and not for some big site, and it would be nice for it to be simple and portable, only requiring the Web server. I'd only prefer MySQL as a last resort, as I don't like having to setup MySQL every time I switch servers, or going through MySQL connection errors.

What should I do / Any suggestions?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

南街九尾狐 2024-12-12 13:40:08

那么你有两个问题:“XML 可以像 MySQL 一样使用吗?” (不,必须区别对待,使用 XPath 而不是 SQL 等)和“XML 可以用于构建 CMS 吗?” (是的,有一些类似的,例如 GetSimple CMS - 请参阅 http://get-simple.info/start/ )
您必须意识到 XML 仅适用于较小量的数据,但在这种情况下您可能不需要数据库的重量。

So you have two questions: "Can XML be used like MySQL?" (No, it must be treated different, use XPath instead of SQL etc.) and "Can XML be used for building a CMS?" (Yes, there are some like that, e.g. GetSimple CMS - see http://get-simple.info/start/)
You must be aware that XML is suitable only for smaller amounts of data, but in that case you probably don't need the weight of a database.

稚气少女 2024-12-12 13:40:07

与 MySQL 相比,我更喜欢 XML,因为它不需要服务器

我更喜欢步行而不是骑轮子旅行,因为它不需要汽车。所以,我每天花 6 个小时上下班。

可以在文本编辑器中编辑 XML

理论上, 。
实际上,XML 受到如此多严格的规则和标准的约束,以至于您几乎无法在不破坏整个文件的情况下编辑逗号。
面对现实——这是针对程序的,而不是针对人类的。

过去我手动将内容列表存储在 *.txt 文件中

您最好进一步坚持这种方法

HTML 表格对此很有用,

HTML 表对此则较差,甚至比 XML 更糟糕。

我想以内容管理系统的形式为我想要显示的任何脚本和文档创建一个索引。

您对内容管理系统的理解是错误的。它是内容管理系统,而不是脚本管理系统。它仅管理存储在某处的内容和数据。

我喜欢将内容与呈现分离的想法,

我也喜欢它,但是您的 XML 与这个想法无关。

我应该做什么/有什么建议吗?

学习驾驶汽车。不要继续行人。
学习数据库。

有趣的阅​​读http://www.joelonsoftware.com/articles/fog0000000319.html

I prefer XML over MySQL because it doesn't require a server

I prefer to travel on foot rather on wheels because it doesn't require a car. So, I spend 6 hours to get to my job and back every day.

XML can be edited within a text-editor

In theory.
In practice, XML is bound with such a number of strict rules and standards that you scarcely can edit a comma without breaking the whole file.
Face the truth - it is for programs, not humans.

In the past I've manually stored lists of stuff in *.txt files

You'd better stick with this approach further

HTML tables are good for this,

HTML tables are worse for this, even worse than XML.

I want to create an index for whatever scripts and documents I'd want to display, in the form of a Content Management System.

You are taking Content Management Systems wrong. It's Content Management System, not scripts management system. It merely manages the content, the data stored somewhere.

I like the idea of separating content from presentation,

I like it too, but your XML has nothing to do with this idea.

What should I do / Any suggestions?

Learn to drive a car. Do not remain a pedestrian.
Learn databases.

An interesting reading http://www.joelonsoftware.com/articles/fog0000000319.html

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文