Insert Batch Method

Insert Batch method is alias of insert_multi method. Insert batch is part of database class builder for inserting multiple data into a table. Is alias of Insert Multi method.


Insert Batch method has 2 required parameters that is table name and values array of array format.

$this->db->insert(string $table_name, array $data_inserts, [bool $is_debug=0]): bool


Data inserts is key value pair in an array. The key refer to column name of the table.

Example usage

Here is the examples using insert multi method. See the first of this page for full example.

Basic Usage

For example we assumed want to add new data in blog table. First, in the model:

class Blog_Model extends SENE_Model{
  var $tbl = 'blog';
  var $tbl_as = 'b';
  public function __construct(){
  public function inserts($dis){

at the controller, we assumed has file named blog.php

class Blog extends Sene_Controller{
  public function __construct(){
    $this->load('blog_model','bm'); #class scope model
  public function index(){
    $id = 1;
    $di = array();

    $dis = array();
    $dis['id'] = 1;
    $dis['title'] = "This is new title of this blog!";
    $dis['content'] = "This is new title of this blog!";

    $dis = array();
    $dis['id'] = 2;
    $dis['title'] = "Test multiple insert";
    $dis['content'] = "This is new test for multiple insert";

    $res = $this->bm->inserts($id,$dis); //call the method on the model
      echo 'Success';
      echo 'failed';