简体   繁体   English

如何使用池建立 PHP PDO 连接

[英]How to establish PHP PDO connection with pooling

I want to connect a Postgres database with pooling:true.我想用 pooling:true 连接 Postgres 数据库。 Can we do it with PHP new PDO option?我们可以使用 PHP 新的 PDO 选项吗? 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; Pooling=true;最小池大小 = 2;内部命令超时 = 0;命令超时 = 0;

I cannot find any such details in https://www.php.net/manual/en/ref.pdo-pgsql.connection.php我在https://www.php.net/manual/en/ref.pdo-pgsql.connection.php中找不到任何此类详细信息

Any help will be much appreciated.任何帮助都感激不尽。

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.据我记得在 PHP 中编程的旧日子,你不能在 PHP 中进行池化,因为 php 不是逐行进行的(大多数时候)并且每个请求都是逐行进行的。 In JavaScript (node.js) you can do pooling, but not on PHP as each request is one thread.在 JavaScript (node.js) 中,您可以进行池化,但不能在 PHP 上进行,因为每个请求都是一个线程。

We can use PgBouncer .我们可以使用PgBouncer This has been answered in another question .这已在另一个问题中得到解答。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM