Ok this is more of a PHP question than mongodb but since i am using mongo as the db i would like to know if there are any issues with both PHP as well as mongo when using the following technique.

I have a page that holds all the html and design (similar to a template). I then have 4 php files that i use as includes. These includes hold html forms which perform CRUD.

My page pulls in a form dynamically by passing in a url variable. The variable tells the page which form/include to load (insert, edit, etc).

Right now I have the db connection and form handling scripts inside each php include file. This means that instead of the db connection and form handling script being called at the top of the page befor html, it is being called within the body of the page.

My question: Is there any know issues with keeping my db connect and form handling scripts inside the include/form (which is loaded in the body) or do i have to call db connection and form handling before any html?

It seems to work just fine but I wanted to post this question to make sure I am not overlooking any potential problems. I would hate to have problems after i put the application into use. thanks for any in site.

有帮助吗?

解决方案

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