> For the complete documentation index, see [llms.txt](https://docs.acpt.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.acpt.io/developers/functions/get_acpt_table_status.md).

# get\_acpt\_table\_status

Get the synchronisation status of a custom table

Retrieve the synchronisation status of a custom table — whether the physical database table is in sync with the stored definition.

### Usage

```php
$status = get_acpt_table_status('products');

if ($status->status === 'not_synced') {
    // $status->diff contains the SQL statements needed to align the table
    foreach ($status->diff as $sql) {
        echo $sql;
    }
}
```

### Parameters

| Parameter   | Type   | Required | Description               |
| ----------- | ------ | -------- | ------------------------- |
| `tableName` | string | Required | Machine name of the table |

### Return

| Type        | Description                                                   |
| ----------- | ------------------------------------------------------------- |
| `\stdClass` | Status object with `status` and `diff` properties (see below) |
| `null`      | When the table definition was not found or on error           |

#### Returned object properties

| Property | Type   | Description                                                                                                                                                                                                                 |
| -------- | ------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `status` | string | One of `not_created` (table does not exist in the DB yet), `synced` (table matches the definition), or `not_synced` (table exists but is out of date)                                                                       |
| `diff`   | array  | SQL statements needed to align the physical table with the stored definition. Contains the full `CREATE TABLE` statement when `status` is `not_created`, or `ALTER TABLE` / column statements when `status` is `not_synced` |
