Skip to content

Commit 4ccdb64

Browse files
welpie21Ekwuno
andauthored
DOC-371: added missing / update methods PHP documentation (#1229)
Co-authored-by: ekwuno <[email protected]>
1 parent 690b454 commit 4ccdb64

30 files changed

+712
-62
lines changed

src/content/doc-sdk-php/core/authentication.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
sidebar_position: 2
33
sidebar_label: Authentication
44
title: Authentication | PHP SDK | Integration | SurrealDB
5-
description: The SurrealDB SDK for PHP enables simple and advanced querying of a remote or embedded database.
5+
description: Learn how to authenticate users and secure the database with the SurrealDB PHP SDK.
66
---
77

88
import Tabs from "@components/Tabs/Tabs.astro";

src/content/doc-sdk-php/core/data-querying.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
sidebar_position: 5
33
sidebar_label: Data Querying
44
title: Data Querying | PHP SDK | Integration | SurrealDB
5-
description: The SurrealDB SDK for PHP enables simple and advanced querying of a remote or embedded database.
5+
description: Learn how to interact with the database and perform CRUD operations using the SurrealDB SDK for PHP.
66
---
77

88
import Tabs from "@components/Tabs/Tabs.astro";

src/content/doc-sdk-php/core/index.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
sidebar_position: 1
33
sidebar_label: SDK Concepts
44
title: PHP SDK Concepts | SDKs | Integration
5-
description: The SurrealDB SDK for PHP enables simple and advanced querying of a remote or embedded database.
5+
description: Learn the core concepts of the SurrealDB SDK for PHP. Understand how to connect to a SurrealDB instance, manage authentication, and interact with the database.
66
---
77

88
# Concepts

src/content/doc-sdk-php/core/initialization.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
sidebar_position: 1
33
sidebar_label: Initialization
44
title: Initialization | PHP SDK | Integration | SurrealDB
5-
description: The SurrealDB SDK for PHP enables simple and advanced querying of a remote or embedded database.
5+
description: Learn how to initialize the SurrealDB SDK for PHP. Understand how to connect to a SurrealDB instance, manage authentication, and interact with the database.
66
---
77

88
import Tabs from "@components/Tabs/Tabs.astro";

src/content/doc-sdk-php/methods/authenticate.mdx

+5-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
sidebar_position: 1
33
sidebar_label: authenticate
44
title: Authenticate Method in PHP | PHP SDK | Integration | SurrealDB
5-
description: The ->authenticate() method for the SurrealDB SDK for PHP authenticates the current connection with a JWT token.
5+
description: Authenticate the current connection with a JWT token using the authenticate method in the SurrealDB PHP SDK.
66
---
77

88
import Label from "@components/shared/Label.astro";
@@ -20,6 +20,7 @@ $db->authenticate($token)
2020
<thead>
2121
<tr>
2222
<th colspan="2" scope="col">Arguments</th>
23+
<th colspan="2" scope="col">Type</th>
2324
<th colspan="2" scope="col">Description</th>
2425
</tr>
2526
</thead>
@@ -29,6 +30,9 @@ $db->authenticate($token)
2930
<code>token</code>
3031
<Label label="required" />
3132
</td>
33+
<td colspan="2" scope="row" data-label="Type">
34+
<code>string</code>
35+
</td>
3236
<td colspan="2" scope="row" data-label="Description">
3337
The JWT authentication token.
3438
</td>
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
sidebar_position: 1
3+
sidebar_label: close
4+
title: Close Method in PHP | PHP SDK | Integration | SurrealDB
5+
description: Close the persistent connection to the database using the close method in the SurrealDB PHP SDK.
6+
---
7+
8+
# `->close()` {#close}
9+
10+
Closes the persistent connection to the database.
11+
12+
```php title="Method Syntax"
13+
$db->close()
14+
```
15+
16+
### Example usage
17+
```php
18+
$db->close();
19+
```

src/content/doc-sdk-php/methods/connect.mdx

+11-4
Original file line numberDiff line numberDiff line change
@@ -2,38 +2,45 @@
22
sidebar_position: 1
33
sidebar_label: connect
44
title: Connect Method in PHP | PHP SDK | Integration | SurrealDB
5-
description: The ->connect() method for the SurrealDB SDK for PHP connects to a local or remote database endpoint.
5+
description: Connect to a local or remote database endpoint using the connect method in the SurrealDB PHP SDK.
66
---
77

88
# `->connect()` {#connect}
99

1010
Connects to a local or remote database endpoint.
1111

1212
```php title="Method Syntax"
13-
$db->connect(url, options)
13+
$db->connect($host, $options)
1414
```
1515

1616
### Arguments
1717
<table>
1818
<thead>
1919
<tr>
2020
<th colspan="2" scope="col">Arguments</th>
21+
<th colspan="2" scope="col">Type</th>
2122
<th colspan="2" scope="col">Description</th>
2223
</tr>
2324
</thead>
2425
<tbody>
2526
<tr>
2627
<td colspan="2" scope="row" data-label="Arguments">
27-
<code>url</code>
28+
<code>host</code>
2829
</td>
30+
<td colspan="2" scope="row" data-label="Type">
31+
<code>string</code>
32+
</td>
2933
<td colspan="2" scope="row" data-label="Description">
3034
The url of the database endpoint to connect to.
3135
</td>
3236
</tr>
33-
<tr>
37+
<tr>
3438
<td colspan="2" scope="row" data-label="Arguments">
3539
<code>options</code>
3640
</td>
41+
<td colspan="2" scope="row" data-label="Type">
42+
<code>associative array</code>
43+
</td>
3744
<td colspan="2" scope="row" data-label="Description">
3845
An object with options to initiate the connection to SurrealDB.
3946
</td>

src/content/doc-sdk-php/methods/create.mdx

+9-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
sidebar_position: 1
33
sidebar_label: create
44
title: Create Method in PHP | PHP SDK | Integration | SurrealDB
5-
description: The ->create() method for the SurrealDB SDK for PHP creates a record in the database.
5+
description: Create a record in the database using the create method with the SurrealDB PHP SDK.
66
---
77

88
import Label from "@components/shared/Label.astro";
@@ -12,14 +12,15 @@ import Label from "@components/shared/Label.astro";
1212
Creates a record in the database.
1313

1414
```php title="Method Syntax"
15-
$db->create(thing, data)
15+
$db->create($thing, $data)
1616
```
1717

1818
### Arguments
1919
<table>
2020
<thead>
2121
<tr>
2222
<th colspan="2" scope="col">Arguments</th>
23+
<th colspan="2" scope="col">Type</th>
2324
<th colspan="2" scope="col">Description</th>
2425
</tr>
2526
</thead>
@@ -29,6 +30,9 @@ $db->create(thing, data)
2930
<code>thing</code>
3031
<Label label="required" />
3132
</td>
33+
<td colspan="2" scope="row" data-label="Type">
34+
<code>string</code>, <code>RecordId</code> or <code>StringRecordId</code>
35+
</td>
3236
<td colspan="2" scope="row" data-label="Description">
3337
The table name or a [`RecordId`](/docs/sdk/php/data-types#recordid) to create.
3438
</td>
@@ -38,6 +42,9 @@ $db->create(thing, data)
3842
<code>data</code>
3943
<Label label="optional" />
4044
</td>
45+
<td colspan="2" scope="row" data-label="Type">
46+
<code>mixed</code>
47+
</td>
4148
<td colspan="2" scope="row" data-label="Description">
4249
The document / record data to create.
4350
</td>

src/content/doc-sdk-php/methods/delete.mdx

+6-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
sidebar_position: 1
33
sidebar_label: delete
44
title: Delete Method in PHP | PHP SDK | Integration | SurrealDB
5-
description: The ->delete() method for the SurrealDB SDK for PHP deletes all or specific records from the database.
5+
description: Delete records from a table in the database using the delete method with the SurrealDB PHP SDK.
66
---
77

88
import Label from "@components/shared/Label.astro";
@@ -12,14 +12,15 @@ import Label from "@components/shared/Label.astro";
1212
Deletes all records in a table, or a specific record, from the database.
1313

1414
```php title="Method Syntax"
15-
$db->delete(thing)
15+
$db->delete($thing)
1616
```
1717

1818
### Arguments
1919
<table>
2020
<thead>
2121
<tr>
2222
<th colspan="2" scope="col">Arguments</th>
23+
<th colspan="2" scope="col">Type</th>
2324
<th colspan="2" scope="col">Description</th>
2425
</tr>
2526
</thead>
@@ -29,6 +30,9 @@ $db->delete(thing)
2930
<code>thing</code>
3031
<Label label="required" />
3132
</td>
33+
<td colspan="2" scope="row" data-label="Type">
34+
<code>string</code>, <code>RecordId</code> or <code>StringRecordId</code>
35+
</td>
3236
<td colspan="2" scope="row" data-label="Description">
3337
The table name or a [`RecordId`](/docs/sdk/php/data-types#recordid) to delete.
3438
</td>

src/content/doc-sdk-php/methods/disconnect.mdx

-19
This file was deleted.
+81
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
---
2+
sidebar_position: 1
3+
sidebar_label: export
4+
title: Export Method in PHP | PHP SDK | Integration | SurrealDB
5+
description: Export data from a local or remote database using the export method with the SurrealDB PHP SDK.
6+
---
7+
8+
import Label from "@components/shared/Label.astro";
9+
10+
# `->export()` {#export}
11+
12+
Exports data from a table.
13+
14+
> [!NOTE]
15+
> This method is only available on a remote database targeted with the http protocol.
16+
17+
18+
```php title="Method Syntax"
19+
$db->export($username, $password);
20+
```
21+
22+
### Arguments
23+
24+
<table>
25+
<thead>
26+
<tr>
27+
<th colspan="2" scope="col">Arguments</th>
28+
<th colspan="2" scope="col">Type</th>
29+
<th colspan="2" scope="col">Description</th>
30+
</tr>
31+
</thead>
32+
<tbody>
33+
<tr>
34+
<td colspan="2" scope="row" data-label="Arguments">
35+
<code>username</code>
36+
<Label label="required" />
37+
</td>
38+
<td colspan="2" scope="row" data-label="Type">
39+
`string`
40+
</td>
41+
<td colspan="2" scope="row" data-label="Description">
42+
The username to authenticate with.
43+
</td>
44+
</tr>
45+
<tr>
46+
<td colspan="2" scope="row" data-label="Arguments">
47+
<code>password</code>
48+
<Label label="required" />
49+
</td>
50+
<td colspan="2" scope="row" data-label="Type">
51+
`string`
52+
</td>
53+
<td colspan="2" scope="row" data-label="Description">
54+
The password to authenticate with.
55+
</td>
56+
</tr>
57+
</tbody>
58+
</table>
59+
60+
### Example
61+
62+
```php title="Example"
63+
64+
// connect to the remote database. For the export to work, the database must exists with also existing data.
65+
$db->connect('http://localhost:8080', [
66+
'namespace' => 'example',
67+
'database' => 'example',
68+
]);
69+
70+
// Export data
71+
$response = $db->export('admin', 'password');
72+
73+
// Create a file and write the response to it
74+
$fp = fopen('exported_data.json', 'w');
75+
76+
// Write the response to the file
77+
fwrite($fp, $response);
78+
79+
// Close the file
80+
fclose($fp);
81+
```
+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
sidebar_position: 1
3+
sidebar_label: health
4+
title: Health Method in PHP | PHP SDK | Integration | SurrealDB
5+
description: Check the storage layer health of a local or remote database using the health method with the SurrealDB PHP SDK.
6+
---
7+
8+
import Label from "@components/shared/Label.astro";
9+
10+
# `->health()` {#health}
11+
12+
This method checks wether the database is running and the storage engine is running.
13+
14+
> [!NOTE]
15+
> This method is only available on a remote database targeted with the http protocol.
16+
17+
```php title="Method Syntax"
18+
$db->health();
19+
```
20+
21+
### Example usage
22+
```php
23+
$health = $db->health();
24+
echo "The health status is: $health."; // 200 or 500
25+
```
26+
27+
The health function returns `200` if the database is running and is in good shape. `500` if a failure occurred.

0 commit comments

Comments
 (0)