SurrealDB Docs Logo

Enter a search query

->query()

Runs a set of SurrealQL statements against the database.

Method Syntax
$db->query($query, $vars)

Arguments

ArgumentsTypeDescription
$query requiredstring

Specifies the SurrealQL statements.

$vars optionalassociative array

Assigns variables which can be used in the query.

Example usage

// Assign the variable on the connection $result = db->query( 'CREATE person SET name = "John"; SELECT * FROM type::table($tb);', [ "tb" => "person" ] ); // Get the first result from the first query $created = $result[0]->result[0]; // Get all of the results from the second query $people = $result[1]->result;