Why specify an explicit database connection?

Ear*_*rlz 3 php postgresql

I am making a simple blog for myself and while reading through the PHP manual, I found this http://us2.php.net/manual/en/function.pg-query.php

It says

resource pg_query ([ resource $connection ], string $query )

...

Note: Although connection can be omitted, it is not recommended, since it can be the cause of hard to find bugs in scripts.

Why is it not ok to just use the last connection? I never plan on having more than 1 connection open per PHP script, so how would this ever cause bugs for me?

zom*_*bat 13

哈."我从不打算每个PHP脚本打开超过1个连接."

我记得我最后一次这么说.它回来了'应该三个.那时我还是个年轻的鞭子,就像你自己一样.充满了吐和醋.如果我不需要,为什么要这样做呢?这是我们的小网络创业公司的主流智慧."完成它吧!" 我们大喊大叫.另外,我们在腰带上戴洋葱.

嗯...时间到了,我在主站点添加了一个快速的小统计数据库.没什么特别的,只是想要分别跟踪一些统计数据.我想我会重新使用数据库包装器.它是时间的好包装!抽象出我需要的所有数据库功能.但是当我在那里添加它时,一些古怪的事情开始发生.它没有意义.我有两个独立的数据库包装器对象......两个独立的连接!他们怎么会相互影响?但随后用户将被随机注销.会话会失败.有时密钥更新会变坏.有些查询在错误的数据库上运行.狗和猫开始一起生活!这是大规模的歇斯底里!

如果我原来只指定了那个连接器.如果我只保留它们,那么pg_query会知道使用哪一个.可以防止如此多的数据丢失.这么多好的元组......这么好的数据.丢失.丢失...

*嗅*