Download the PHP package voryx/pgasync without Composer
On this page you can find all versions of the php package voryx/pgasync. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download voryx/pgasync
More information about voryx/pgasync
Files in voryx/pgasync
Informations about the package pgasync
PgAsync
Asynchronous Reactive Postgres Library for PHP (Non-blocking)
What it is
This is an asynchronous Postgres library for PHP. Observables are returned by the query methods allowing asynchronous row-by-row data handling (and other Rx operators on the data) See Rx.PHP. Network and event processing is handled by ReactPHP.
This is a pure PHP implementation (you don't need Postgres extensions to use it).
Example - Simple Query
Example - parameterized query
Example - LISTEN/NOTIFY
Install
With composer install into you project with:
Install pgasync:
What it can do
- Run queries (CREATE, UPDATE, INSERT, SELECT, DELETE)
- Queue commands
- Return results asynchronously (using Observables - you get data one row at a time as it comes from the db server)
- Prepared statements (as parameterized queries)
- Connection pooling (basic pooling)
What it can't quite do yet
- Transactions (Actually though, just grab a connection and you can run your transaction on that single connection)
What's next
- Add more testing
- Transactions
- Take over the world
Keep in mind
This is an asynchronous library. If you begin 3 queries (subscribe to their observable):
It will start all of them almost simultaneously (and you will begin receiving rows on all 3 before any of them have completed). This can be great if you want to run 3 queries at the same time, but if you have some queries that need information that was modified by other statements, this can cause a race condition:
In the above situation, your balance may or may not include the invoice inserted on the first line.
You can avoid this by using the Rx concat* operator to only start up the second observable after the first has completed:
Testing
We use docker to run a postgresql instance for testing. To run locally, just install docker and run the following command from the project root:
If you need to reset the database, just stop the docker instance and delete
the docker/database
directory. Restart the docker with the above command and it will
initialize the database again.
The tests do not change the ending structure of the database, so you should not normally need to do this.
All versions of pgasync with dependencies
voryx/event-loop Version ^3.0 || ^2.0.2
reactivex/rxphp Version ^2.0
react/socket Version ^1.0 || ^0.8 || ^0.7
evenement/evenement Version ^2.0 | ^3.0