https://github.com/savander/surrealdb-client
The client for SurrealDB database.
https://github.com/savander/surrealdb-client
php php-client php8 surrealdb surrealdb-database
Last synced: 7 months ago
JSON representation
The client for SurrealDB database.
- Host: GitHub
- URL: https://github.com/savander/surrealdb-client
- Owner: savander
- License: mit
- Created: 2022-09-20T12:39:04.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-10-03T18:22:37.000Z (over 3 years ago)
- Last Synced: 2025-01-24T10:32:40.322Z (about 1 year ago)
- Topics: php, php-client, php8, surrealdb, surrealdb-database
- Language: PHP
- Homepage:
- Size: 32.2 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
Awesome Lists containing this project
README
# SurealDB Client
> # ⚠️ Warning!
> The package is in the very early stages of development!
The client allows you to connect to SurrealDB and perform queries.
## Installation
You can install the package via composer:
```bash
composer require savander/surrealdb-client
```
## Usage
```php
// The connection options.
$connectionOptions = (new ConnectionOptions())
->setNamespace('test')
->setDatabase('test')
->setUsername(getenv('DB_USER'))
->setPassword(getenv('DB_PASS'));
// The persistent connection to the SurrealDB Websocket server.
$connection = new Connection($connectionOptions);
// The results of the query. It returns the Johnny :)
$createdJohnny = $connection
->raw("CREATE author SET name.first = 'Johnny'")
->results();
// The results of the selection query, it returns the previously created Johnny.
// > Please note that, we used `prepare` method here. It's much safer to do this that way.
// > In this case, we are sending attributes as a separate array of arguments.
// > You could use that method in previous step as well.
$selectedJohnny = $connection
->prepare('SELECT * FROM $author', ['author' => $createdJohnny['id']])
->results();
```
## Contributing
Please see [CONTRIBUTING](CONTRIBUTING.md) for details.
## License
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.