好的,这是比MongoDB更多的PHP问题,但由于我使用Mongo作为DB时,我想知道使用以下技术时是否存在任何PHP以及Mongo。

我有一个包含所有HTML和设计的页面(类似于模板)。然后我有4个我使用的PHP文件。这些包括保持执行CRUD的HTML表单。

我的页面通过在URL变量中动态地拉动形式。该变量告诉该页面,该页面/包含加载(插入,编辑等)。

现在我有DB连接,并在每个PHP中的处理脚本包括文件。这意味着代替DB连接和表单处理脚本在页面顶部被调用为HTML,它在页面的正文中被调用。

我的问题:保留我的DB Connect并在包含/表单中的操作脚本(装入正文中加载的脚本)或者我必须在任何HTML之前调用DB连接和表单处理?

它似乎工作得很好,但我想发布这个问题,以确保我不忽视任何潜在的问题。在将申请放入使用后,我会讨厌出现问题。谢谢您的任何网站。

有帮助吗?

解决方案

Yes, this is fine. All PHP is processed before the HTML is rendered as output so even if you're including php files after outputting some HTML, it will still be processed before anything is sent back to the browser.

其他提示

There is no problem - you can connect to mongodb in every point. Just keep in mind, that you should re-use connections, if you want to execute more than one query.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top