Core\Db\Connection
An open connection to one database. It runs SQL queries and statements, and it starts transactions.
Returned by
You get a Core\Db\Connection from these methods:
Members
11 members.
| Member | Signature |
|---|---|
query | query(string $sql, array<mixed> $params, { timeout?: Core\Time\Duration }): Core\Db\Rows<Core\Db\Row> |
queryAs | queryAs<T>(string $sql, array<mixed> $params, { timeout?: Core\Time\Duration }): Core\Db\Rows<T> |
execute | execute(string $sql, array<mixed> $params, { timeout?: Core\Time\Duration }): Core\Db\Write |
executeMany | executeMany(string $sql, array<array<mixed>> $sets, { timeout?: Core\Time\Duration }): uint |
queryEach | queryEach(string $sql, array<mixed> $params, { timeout?: Core\Time\Duration }): Core\Db\Stream<Core\Db\Row> |
queryEachAs | queryEachAs<T>(string $sql, array<mixed> $params, { timeout?: Core\Time\Duration }): Core\Db\Stream<T> |
runTransaction | runTransaction(callable(Core\Db\Transaction): T $fn, { isolation?: Core\Db\Isolation, readOnly?: bool, retries?: uint }): T |
close | close(): void |
driver | driver(): Core\Db\Driver |
serverVersion | serverVersion(): string |
isOpen | isOpen(): bool |
Example apps
These complete apps use this class. You can download and run each one.
- Chat: A chat app with rooms, WebSockets and SQLite. One Novis server sends the pages and runs every connection, with no separate WebSocket server and no library.
- Notes: A small notes app with SQLite, HTML pages, a JSON API, form checks and tests. Download it, run it and start your own app from it.
- Poll: A live poll with SQLite and server-sent events. Every open page shows each new vote at once, with no extra server and no library.
