Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Best way to connect to DB in a large project

Status
Not open for further replies.

SatishPutcha

Programmer
Mar 12, 2002
256
IN
Hello Everybody

I have taken up my first PHP-mySQL project and it is quite huge. I have to create a database connection and I intend to put in a file that I will include in my PHP pages and keep reusing.

I wanted to know if it is a good practice to use inbuilt mySQL functions for this purpose i.e. mysql_connect, mysql_select_db, mysql_query, mysql_num_fields, mysql_fetch_array, etc.

If not what is the best way to go about it?

Thanks and Regards
Satish Kumar
 
I don't know since I am very new to PHP. But I was wondering if I should create an ODBC connection and put it in a session variable. Does that make sense?

Regards
Satish
 
I understand what you are proposing, but it won't work, as you can't store a handle (either a file handle or a database handle) in a session.

Also, if you have a choice between ODBC and database-specific libraries, always use the database-specific libraries. ODBC was designed to be flexible, not high-performance.

If you are worried about overhead with opening new database connections, I recommend you take a look at mysql_pconnect().

Want the best answers? Ask the best questions!

TANSTAAFL!!
 
OK. I understood the part about ODBC vis-a-vis database specific libraries. I will also look into mysql_pconnect().

Thank you very much sleipnir214!!

Regards
Satish
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top