Skip to content

savander/surrealdb-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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:

composer require savander/surrealdb-client

Usage

// 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 for details.

License

The MIT License (MIT). Please see License File for more information.

About

The client for SurrealDB database.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages