mirror of
https://github.com/codeguy/php-the-right-way.git
synced 2025-08-13 09:13:58 +02:00
Added small paragraph on connections
Some developers (maybe not newbies, but more coming from other languages) will be wondering if you have to close connections. I think a quick touch on database connections and their automatic closing on script end is a helpful addition.
This commit is contained in:
@@ -52,6 +52,14 @@ database preventing potential SQL injection attacks.
|
||||
|
||||
* [Learn about PDO][1]
|
||||
|
||||
You should also be aware that database connections use up resources and it was not unheard-of to have resources
|
||||
exhausted if connections were not implicitly closed, however this was more common in other languages. Using PDO you
|
||||
can implicitly close the connection by destroying the object by ensuring all remaining references to it are deleted,
|
||||
ie. set to NULL. If you don't do this explicitly, PHP will automatically close the connection when your script ends
|
||||
unless of course you are using persistent connections.
|
||||
|
||||
* [Learn about PDO connections][5]
|
||||
|
||||
## Abstraction Layers
|
||||
|
||||
Many frameworks provide their own abstraction layer which may or may not sit on top of PDO. These will often emulate features for
|
||||
@@ -69,6 +77,7 @@ Some abstraction layers have been built using the PSR-0 namespace standard so ca
|
||||
[2]: http://www.doctrine-project.org/projects/dbal.html
|
||||
[3]: http://framework.zend.com/manual/en/zend.db.html
|
||||
[4]: http://packages.zendframework.com/docs/latest/manual/en/index.html#zend-db
|
||||
[5]: http://php.net/manual/en/pdo.connections.php
|
||||
|
||||
[mysql]: http://uk.php.net/mysql
|
||||
[mysqli]: http://uk.php.net/mysqli
|
||||
|
Reference in New Issue
Block a user