0

Possible duplicates: Connection pooling in PHP and php connection pooling mysql

I used to restore connections in $_SESSION.

but found it not good.

Community
  • 1
  • 1
omg
  • 136,412
  • 142
  • 288
  • 348

2 Answers2

3

It is impossible to implement a database pool in php, because each request runs in a completely new process. There is nothing that survives between requests. The library may have its own database pool (In the mysql api, it's called persistent connections). For mysql, it's moot point though, since the cost of establishing a new connection is minuscule.

troelskn
  • 115,121
  • 27
  • 131
  • 155
  • this is not the case anymore. use swoole/openswoole to gain connection pool and many many other async enterprise features. – Dannyboy Jun 02 '22 at 12:14
-1

It is not minuscule, database connection is the most time consuming step while connecting to DB irrespective of the technology.