Hi,
Currently i have a class for connecting to mysql which i use in my php website, the constructor connects to the mysql db, and a function setdb allows me to change what database is selected etc.
However, i hear classes aren't very efficient in php, and decided to change my approach, but i thought i might as well ask if anyone knew what the best approach would be???
I think i use a database in someway on each page so i was thinking i should put all the Mysql_connect() stuff in a seperate file and use include_once to connect automatically?
Also what about closing the database? is it necessary? If im using the database throughout the entire script there is no benefit on closing it early.
So can i just omit the close function and let php terminate the connection automatically when the script ends?
Currently i have a class for connecting to mysql which i use in my php website, the constructor connects to the mysql db, and a function setdb allows me to change what database is selected etc.
However, i hear classes aren't very efficient in php, and decided to change my approach, but i thought i might as well ask if anyone knew what the best approach would be???
I think i use a database in someway on each page so i was thinking i should put all the Mysql_connect() stuff in a seperate file and use include_once to connect automatically?
Also what about closing the database? is it necessary? If im using the database throughout the entire script there is no benefit on closing it early.
So can i just omit the close function and let php terminate the connection automatically when the script ends?