Closed fakharksa closed 1 year ago
Please find PDO pool example at: https://github.com/openswoole/openswoole/blob/master/example/src/Coroutine/MySQLClientPool.php Postgres client pool example at: https://github.com/openswoole/openswoole/blob/master/example/src/Coroutine/PostgresClientPool.php
<?php declare(strict_types=1); include (dirname(DIR).'/config/db_config.php');
use Swoole\Coroutine\PostgreSQL; use Swoole\Database\PDOConfig; use Swoole\Database\PDOPool; use Swoole\Runtime;
const POSTGRES_SERVER_HOST = 'localhost'; const POSTGRES_SERVER_PORT = 5432; const POSTGRES_SERVER_DB = 'swooledb'; const POSTGRES_SERVER_USER = 'postgres'; const POSTGRES_SERVER_PWD = 'passwd123';
No Error
PHP Fatal error: Uncaught Error: Class "Swoole\Database\PDOPool" not found in /var/www/html/swoole-prac/bootstrap/db_connection_pool.php:49 Stack trace:
0 /var/www/html/swoole-prac/sw_service.php(92): create_db_connection_pool()
1 [internal function]: sw_service->{closure}()
2 {main}
thrown in /var/www/html/swoole-prac/bootstrap/db_connection_pool.php on line
openswoole
Open Swoole => enabled Author => Open Swoole Group hello@openswoole.com Version => 22.0.0 Built => Jan 13 2023 22:50:54 coroutine => enabled with thread context debug => enabled trace_log => enabled epoll => enabled eventfd => enabled signalfd => enabled cpu_affinity => enabled spinlock => enabled rwlock => enabled sockets => enabled openssl => OpenSSL 3.0.2 15 Mar 2022 dtls => enabled http2 => enabled c-ares => 1.18.1 zlib => 1.2.11 mutex_timedlock => enabled pthread_barrier => enabled futex => enabled mysqlnd => enabled postgresql => enabled
Directive => Local Value => Master Value openswoole.enable_coroutine => On => On openswoole.enable_preemptive_scheduler => Off => Off openswoole.display_errors => On => On openswoole.unixsock_buffer_size => 8388608 => 8388608
uname -a Linux fakhar-HP-Laptop 5.17.5-76051705-generic #202204271406~1651504840~20.04~63e51bd-Ubuntu SMP PREEMPT Wed Ma x86_64 x86_64 x86_64 GNU/Linux
PHP Version: PHP 8.1.14 (cli) (built: Jan 6 2023 15:23:18) (NTS) Copyright (c) The PHP Group Zend Engine v4.1.14, Copyright (c) Zend Technologies with Zend OPcache v8.1.14, Copyright (c), by Zend Technologies
GCC Version: gcc version 11.3.0 (Ubuntu 11.3.0-1ubuntu1~22.04)