This repository was archived by the owner on Sep 28, 2022. It is now read-only.
File tree 1 file changed +43
-14
lines changed
1 file changed +43
-14
lines changed Original file line number Diff line number Diff line change 1
- ### install
2
-
3
- 1 . Make sure you have installed the latest version of swoole (swoole version >= 4.4)
4
-
5
- 2 . build:
6
- ```
7
- phpize
8
- ./configure
9
- make && make install
10
- ```
11
- 3. edit your php.ini :
12
- ```
13
- extension=swoole_postgresql.so
14
- ```
1
+ # Swoole Coroutine Postgres Client
2
+
3
+ ` ext-postgresql ` is the Swoole Postgres Client library can be used with in the coroutine context without blocking.
4
+
5
+ ### Pre-requirement
6
+
7
+ * ` libpq ` is required
8
+ * ` swoole ` version >= 4.4.0
9
+
10
+ ### Build & Installation
11
+
12
+ ``` bash
13
+ git clone
[email protected] :swoole/ext-postgresql.git
14
+ phpize
15
+ ./configure
16
+ make && make install
17
+ ```
18
+
19
+ Enable ` swoole_postgresql ` in php.ini by adding the following line:
20
+ ```
21
+ extension=swoole_postgresql.so
22
+ ```
23
+
24
+ ### How to use the Postgres Client
25
+
26
+ ``` php
27
+ <?php
28
+ Co\run(function () {
29
+ $db = new Swoole\Coroutine\PostgreSQL();
30
+ $db->connect("host=127.0.0.1 port=5432 dbname=test user=root password=password");
31
+ $db->prepare('fortunes', 'SELECT id, message FROM Fortune');
32
+ $res = $db->execute('fortunes', []);
33
+ $arr = $db->fetchAll($res);
34
+ var_dump($arr);
35
+
36
+ $db->prepare('select_query', 'SELECT id, randomnumber FROM World WHERE id = $1');
37
+ $res = $db->execute('select_query', [123]);
38
+ $ret = $db->fetchAll($res);
39
+ var_dump($ret);
40
+ });
41
+ ```
42
+
43
+ You can find more examples in the ` /examples ` folder.
15
44
16
45
17
46
You can’t perform that action at this time.
0 commit comments