Insert Query in Codeigniter

Generates an insert string based on the data you supply, and runs the query. You can either pass an array or an object to the function.

Note: All values are escaped automatically producing safer queries.

Let’s create a inser() method in codeigniter

$data = array(
        'title' => 'php',
        'name' => 'alex',
        'status' => '1'
);

$this->db->insert('mytable', $data);
// Produces: INSERT INTO mytable (title, name, status) VALUES ('php', 'alex', '1')

Leave a Reply

Your email address will not be published. Required fields are marked *