SurrealDB Docs Logo

Enter a search query

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

FunctionDescription
$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

FunctionDescription
$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

FunctionDescription
$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

FunctionDescription
$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

On this page

© SurrealDB GitHub Discord Community Cloud Features Releases Install