Insert Multi Method

The insert_multi method purpose is for inserting multiple rows data into a table. This method is part from Query Builder methods.

Basic Usage

Here is the basic usage insert_multi method from $db property on SENE_Model class.

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


This method has 2 required parameters and 1 optional parameter.


The $table_name refers to the name of the table to which the data is to be inserted.


The $data_inserts value can contain 2 dimension array. The first dimension array are the data sequencer. Each data sequencer contain an array with key value pair. The array key refer to column name of the table and the value refer to value that will be inserted. This value supported MySQL builtin functions and values, such as:

  • NOW()
  • NULL


This examples will show implementation insert_multi method on class model and then how to executing the method on controller class.

The Model Class Example

Here is the source code example for Blog_Model class.

class Blog_Model extends SENE_Model{
  var $tbl = 'blog';
  var $tbl_as = 'b';

  public function __construct(){
  public function inserts($dis){

The Controller Class Example

Here is the source code for controller class example using insert_multi method.

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'] = "Hello World";
    $dis['content'] = "Congratulation, your first blog!";
    $dis['date_publish'] = "NULL";

    $dis = array();
    $dis['id'] = 2;
    $dis['title'] = "Seme Framework Awesome!";
    $dis['content'] = "Lorem lipsum dolor sit ame, what is lorem lipsum?";
    $dis['date_publish'] = "NOW()";

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

SQL Result

The following is the SQL command that generated from Blog controller while executing insert_multi method.

INSERT INTO blog (id,title,content,date_publish)
  (1,"Hello World","Congratulation, your first blog!",NULL),
  (2,"Seme Framework Awesome!","Lorem lipsum dolor sit ame, what is lorem lipsum?",NOW())