> 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/save.md).

# save

Upsert(Update/Insert) a record.

**Usage:**

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

<pre class="language-php"><code class="lang-php"><strong>// First we search our data
</strong><strong>$news = $db->news->findOne(1);
</strong><strong>if (empty($news)) {
</strong><strong>    // If not existing declare new data
</strong><strong>    $news = new News();
</strong><strong>}
</strong><strong>
</strong><strong>$news->name = 'My Name';
</strong><strong>$news->status = 'ACTIVE'
</strong><strong>
</strong><strong>$data = $db->news->save($news);
</strong></code></pre>

**Return:**

```json
// If existing updates the record
{
    id: 1,
    name: 'My Name',
    created_at: '..',
    updated_at: '..',
    deleted_at: null
}
// If not creates a new record
{
    id: 2,
    name: 'My Name',
    created_at: '..',
    updated_at: null,
    deleted_at: null
}
```
