• Start

v1 (stable)

/

Methods

let

Assign parameters to a query using the let method in the SurrealDB PHP SDK.

Assigns a value as a parameter for this connection.

Method Syntax
$db->let($name, $value)

Arguments

Type

Description

namestring

Specifies the name of the variable.

valuemixed

Assigns the value to the variable name.

// Assign the variable on the connection
$db->let('name', [
	"first" => "Tobie",
	"last" => "Morgan Hitchcock",
]);

// Use the variable in a subsequent query
$db->query('CREATE person SET name = $name');

// Use the variable in a subsequent query
$db->query('SELECT * FROM person WHERE name.first = $name.first');

You can remove the variable from the connection using the unset() method.

Was this page helpful?