How to establish PHP PDO connection with pooling

1k Views Asked by At

I want to connect a Postgres database with pooling:true. Can we do it with PHP new PDO option? If not are there any reliable options?

I want to pass the below parameters(similar) while establishing the connection:

Pooling=true;Minimum Pool Size = 2;Internal Command Timeout = 0;Command Timeout = 0;

I cannot find any such details in https://www.php.net/manual/en/ref.pdo-pgsql.connection.php

Any help will be much appreciated.

2

There are 2 best solutions below

0
Seti On BEST ANSWER

As far as i remember from old days of programming in PHP, You cannot have pooling in PHP as php is not threded (most of times) and each requests goes line by line. In JavaScript (node.js) you can do pooling, but not on PHP as each request is one thread.

1
K M On

We can use PgBouncer. This has been answered in another question.