| | |||||
| ||||||||
| Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics. |
![]() |
| | LinkBack | Thread Tools |
| | THREAD STARTER #1 (permalink) |
| NamePros Regular Join Date: May 2008
Posts: 246
![]() ![]() | One MYSQL connection per function or big no no? I'm currently learning how to make PHP and MYSQL be buddies. So far I've created a connection function and I use it in every other function in order to shorten the code. Since I'm connecting to the MYSQL server (service on the apache server?) every single relevant function call, and I making huge overhead? Or is this normal behavior for talking with MYSQL? Should I just call the connect function, run my other functions, and then close? Thanks.
__________________ Are you tired of viruses and popups? Use Firefox! |
| | |
| | #2 (permalink) |
| NamePros Member Join Date: Aug 2008 Location: poland
Posts: 94
![]() | Theres no need to open up the connection for every function if you use them one after another. Usually you can connect per script or if you use classes in PHP The Singleton Design Pattern for PHP
__________________ |
| | |
| | #4 (permalink) | ||||
| Tech Support Join Date: Mar 2005
Posts: 4,944
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
![]() PHP Code: | ||||
| | |
![]() |
| Tags |
| mysql, mysql_connect(), php |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| |