> 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` |
| `engine`       | string\|null | The storage engine the database table actually uses (for example `InnoDB` or `MyISAM`). `null` when the table doesn't exist. Available since 2.1.10                                                                         |
| `innodb_query` | string\|null | The `ALTER TABLE … ENGINE=InnoDB` statement that moves the table to InnoDB, when it uses an engine without transactions and foreign keys (such as MyISAM). `null` otherwise. Available since 2.1.10                         |

#### Checking the storage engine

A table created before ACPT 2.1.10 on a server whose default engine is MyISAM may still be MyISAM, and still show as `synced` (see [Tables](https://docs.acpt.io/custom-content-types/tables.md#storage-engine)).

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

if ($status && $status->innodb_query !== null) {
    // the table is not on InnoDB: $status->engine says which engine it uses
}
```
