# Insert

This is for the inserting a row in the table. Where`$form_data` is array `[ "table-column" => "value" ]`. The last parameter is optional only, default value is `"N"` means nothing to fetch and if it is set to `"Y"` the method will return the `lastInsertId`.

```php
// DB()->insert($table, $form_data, $lastInsertId = 'N');

<?php

namespace App\Controllers;

class UserController
{
    public function store()
    {
        $form_data = [
            'email' => 'j@testmail.com',
            'fullname' => 'Judywen Guapin'
        ];

        DB()->insert('users', $form_data);
    }
}
```

Take note that the `email` and `fullname` is the column name in your selected table which is `users`.

Always remember that the `insert` method return a integer result, if the result is `1` it is true then `0` is false. False if the query produce an error and true if the query is successfully executed against the database.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://sprnva.gitbook.io/sprnva-docs/database/insert.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
