> For the complete documentation index, see [llms.txt](https://jls-organization-3.gitbook.io/projecthyper/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://jls-organization-3.gitbook.io/projecthyper/features/quickstart/insert.md).

# insert

Insert a new record.

**Usage:**

```php
$db->{table}->insert($data);
```

**Example:**

| Table                  | Model              | Database                    |
| ---------------------- | ------------------ | --------------------------- |
| news                   | News               | $db->news                   |
| news\_details          | NewsDetails        | $db->news\_details          |
| news\_attachments\_ids | NewsAttachmentsIds | $db->news\_attachments\_ids |

```php
// First declare your model
// where "News" is your table name in capital case
$data = new News();
$data->name = 'My news';
$data->status = 'ACTIVE';

$news = $db->news->insert($data);
echo json_encode($news);
```

**Return:**

```json
{
    "id": "AUTO_GENERATED_ID",
    "name": "Test News",
    "status": "ACTIVE",
    "created_at": "2024-11-03 21:07:37",
    "updated_at": null,
    "deleted_at": null
}
```
