MySql Correct Method of Coding
Posted: Mon Nov 20, 2006 8:43 am
Hi guys,
First time poster on here and I apologise for the stupid post.
I have numerous sites written in PHP. I have different coding approaches to my database access. Can someone post up a code snippet where needed as well as answering some of my questions?
Q. Should I open and close my connection per request to the database or per page?
Q. Does the connection close automatically once the page dies, or am I risking open connections?
Q. When I make a select request to the database and I get no data back, what is the best method of handling this?
Q. Can you post a code snippet on a standard way of making an SQL Request to the database and then accessing the data, including error handling and dealing with empty datasets?
Its just I have become somewhat confused as the best methods to do things and lately my MySql server is dying from my crass db code. I need some STANDARDS guidance once and for all
Help? Please....
First time poster on here and I apologise for the stupid post.
I have numerous sites written in PHP. I have different coding approaches to my database access. Can someone post up a code snippet where needed as well as answering some of my questions?
Q. Should I open and close my connection per request to the database or per page?
Q. Does the connection close automatically once the page dies, or am I risking open connections?
Q. When I make a select request to the database and I get no data back, what is the best method of handling this?
Q. Can you post a code snippet on a standard way of making an SQL Request to the database and then accessing the data, including error handling and dealing with empty datasets?
Its just I have become somewhat confused as the best methods to do things and lately my MySql server is dying from my crass db code. I need some STANDARDS guidance once and for all
Help? Please....