SDK methods
The SurrealDB SDK for PHP has a single SurrealDB class that provides methods for querying a remote SurrealDB database. The class is designed to be simple to use and easy to understand for developers who are new to PHP or SurrealDB. This page lists out the methods that are available in the SurrealDB class.
Initialization methods
Function | Description |
---|---|
$db->connect(url, options) | Connects to a local or remote database endpoint |
$db->disconnect() | Closes the persistent connection to the database |
$db->use(options) | Switch to a specific namespace and database |
$db->let(key,val) | Assigns a value as a parameter for this connection |
$db->unset(key) | Removes a parameter for this connection |
Query methods
Function | Description |
---|---|
$db->query(sql,vars) | Runs a set of SurrealQL statements against the database |
$db->select(thing) | Selects all records in a table, or a specific record |
Mutation methods
Function | Description |
---|---|
$db->create(thing,data) | Creates a record in the database |
$db->insert(thing,data) | Inserts one or multiple records in the database |
$db->update(thing,data) | Updates all records in a table, or a specific record |
$db->merge(thing,data) | Modifies all records in a table, or a specific record |
$db->patch(thing,data) | Applies JSON Patch changes to all records in a table, or a specific record |
$db->delete(thing,data) | Deletes all records, or a specific record |
Authentication methods
Function | Description |
---|---|
$db->signup(vars) | Signs this connection up to a specific authentication scope |
$db->signin(vars) | Signs this connection in to a specific authentication scope |
$db->invalidate() | Invalidates the authentication for the current connection |
$db->authenticate(token) | Authenticates the current connection with a JWT token |
$db->info() | Returns the record of an authenticated scope user |