• Start

Languages

/

PHP

/

Methods

export

Export data from a local or remote database using the export method with the SurrealDB PHP SDK.

Exports data from a table.

Method Syntax

$db->export($username, $password);
ArgumentsTypeDescription
username string The username to authenticate with.
password string The password to authenticate with.

Example

// connect to the remote database. For the export to work, the database must exists with also existing data.
$db->connect('http://localhost:8080', [
'namespace' => 'example',
'database' => 'example',
]);

// Export data
$response = $db->export('admin', 'password');

// Create a file and write the response to it
$fp = fopen('exported_data.json', 'w');

// Write the response to the file
fwrite($fp, $response);

// Close the file
fclose($fp);

Was this page helpful?