Section 23.7. Use Persistent Connections


23.7. Use Persistent Connections

If you connect to a database with each script, consider using a persistent connection rather than a normal connection. For MySQL users, that is the difference between using mysql_pconnect( ) rather than mysql_connect( ). Persistent connections remain connected even after your script has ended, which means that the next time a script asks for a connection, it uses the one that is already openthis saves a lot of time negotiating passwords and such that can otherwise be used to execute important code.

Switching to persistent connections does not require any other change than adding a "p" in the function namethe parameters are still the same. If your database server is not on the same machine as your web server, consider using CLIENT_COMPRESS as the fifth parameter to your mysql_connect( )/mysql_pconnect( ) call, as it allows MySQL to compress data to save space, and can drastically lower network bandwidth and transfer speed, particularly when reading in lots of data.



PHP in a Nutshell
Ubuntu Unleashed
ISBN: 596100671
EAN: 2147483647
Year: 2003
Pages: 249

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net