hyperf / db-pgsql-incubator
Installs: 3 525
Dependents: 0
Suggesters: 0
Security: 0
Stars: 4
Watchers: 3
Forks: 4
Open Issues: 2
Requires
- php: >=7.3
- hyperf/db: ^2.1
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.0
- hyperf/di: ^2.1
- hyperf/testing: ^2.1
- hyperf/utils: ^2.1
- mockery/mockery: ^1.0
- phpstan/phpstan: ^0.12
- phpunit/phpunit: >=7.0
- swoole/ide-helper: dev-master
- symfony/var-dumper: ^5.1
README
安装
hyperf/db 组件版本必须大于等于 v2.1.8
composer require hyperf/db-pgsql-incubator
配置
修改 autoload/db.php
配置
use Hyperf\DB\PgSQL\PgSQLPool; return [ 'default' => [ 'driver' => PgSQLPool::class, 'host' => '127.0.0.1', 'port' => 5432, 'database' => 'postgres', 'username' => 'postgres', 'password' => 'root', 'pool' => [ 'min_connections' => 1, 'max_connections' => 32, 'connect_timeout' => 10.0, 'wait_timeout' => 3.0, 'heartbeat' => -1, 'max_idle_time' => 60, ], ], ];
使用
具体使用方式与 PDO 一致,只不过需要注意,pgsql
中的变量使用 $1
而不是 ?
代表。
例如下述代码
<?php use Hyperf\DB\DB; $res = DB::query('SELECT * FROM USERS WHERE id = $1 AND nickname = $2;', [2, 'Hyperf']);