# run

The run method in the SurrealDB PHP SDK allows you to execute a defined SurrealQL function on the remote database.

Runs a defined SurrealQL function on the remote database.

```php title="Method Syntax"
$db->run($function, $version, $params);
```

## Arguments

<table>
	<thead>
		<tr>
			<th colspan="2" scope="col">Arguments</th>
			<th colspan="2" scope="col">Type</th>
			<th colspan="2" scope="col">Description</th>
		</tr>
	</thead>
	<tbody>
		<tr>
			<td colspan="2" scope="row" data-label="Arguments">
				<code>$function</code>
				<label label="required" />
			</td>
			<td colspan="2" scope="row" data-label="Description">
				<code>string</code>
			</td>
			<td colspan="2" scope="row" data-label="Description">
				The name of the function to run.
			</td>
		</tr>
		<tr>
			<td colspan="2" scope="row" data-label="Arguments">
				<code>$version</code>
				<label label="optional" />
			</td>
			<td colspan="2" scope="row" data-label="Type">
				`string` or `null`
			</td>
			<td colspan="2" scope="row" data-label="Description">
				The version of the function to run.
			</td>
		</tr>
		<tr>
			<td colspan="2" scope="row" data-label="Arguments">
				<code>$params</code>
				<label label="optional" />
			</td>
			<td colspan="2" scope="row" data-label="Type">
				`array` or `null`
			</td>
			<td colspan="2" scope="row" data-label="Description">
				An array of parameters to pass to the function.
			</td>
		</tr>
	</tbody>
</table>

## Example

```php title="Example"
$functionA = $db->run("fn::hello_world", null, ["Tobie"]);
$functionB = $db->run("fn::hello_world", "v1", ["Tobie"]);

// or with named arguments
$functionA = $db->run("fn::hello_world", params: ["Tobie"]);
$functionB = $db->run("fn::hello_world", version: "v1", params: ["Tobie"]);
```
