如何在codeigniter中将数据插入数据库? [关闭]

I am new in this work I have created simple form in view folder like this:

 <form action="" method="post" enctype="multipart/form-data">
       <table>
                <tr>
                    <td>Book Title</td>
                    <td><input type="text" name="title" /></td>
                </tr>
                <tr>
                    <td>Book Author</td>
                    <td><input type="text" name="author" /></td>
                </tr>
                <tr>
                    <td>Book Image</td>
                    <td><input type="file" name="image" /></td>
                </tr>
               
                <tr>
                    <td>Book Description</td>
                    <td><input type="text" name="content" /></td>
                </tr>
                <tr>
                    <td><input type="submit" name="submit" /></td>
                </tr>
        </table>
        </form>

and i receive form data in controller like this:

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Welcome extends CI_Controller {

    
    public function index()
        {
            $this->load->view('insert/post');
            
           $title = $this->input->post('title');
           $author = $this->input->post('author');
           $image = $this->input->post('image');
           $content = $this->input->post('content');
                               
        }
    
  }

but how to insert these data into database kindly help with simple codes.

</div>
$this->db->query(
    'INSERT INTO tbl (a, b, c, d) VALUES (?, ?, ?, ?)',
    array($a, $b, $c, $d)
);

or

$this->db->insert('tbl', array($a, $b, $c, $d));

Get last insert ID:

$idOfInsertedData = $this->db->insert_id();

Here you go

application/controllers/Welcome.php

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Welcome extends CI_Controller {


    public function index()
    {   
        // If you have post data...
        if (!empty($_POST)) {
            $title = $this->input->post('title');
            $author = $this->input->post('author');
            $image = $this->input->post('image');
            $content = $this->input->post('content');
            // Checking if everything is there
            if ($title && $author && $image && $content) {
                // Loading model
                $this->load->model('exemple_model');
                $data = array(
                    'title' => $title,
                    'author' => $author,
                    'image' => $image,
                    'content' => $content
                );

                // Calling model
                $id = $this->exemple_model->insert($data);

                // You can do something else here
            }
        }
        // Loading view
        $this->load->view('insert/post');                       
    }

}

application/models/Exemple_model.php

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Exemple_model extends CI_Model {


    public function insert($data) {
        // Inserting into your table
        $this->db->insert('MyTable', $data);
        // Return the id of inserted row
        return $idOfInsertedData = $this->db->insert_id();
    }

}