title: Insert data from array_push to database in codeigniter
body: <p>Hi i hava data in array like this :</p>
  
  <pre><code>$data = Array
         (
  [0] =&gt; Array
      (
          [kode_pbt] =&gt; PBT3-2012-10-19
          [kodebr] =&gt; 8992802618731
          [harga] =&gt; 25905.00
          [jml] =&gt; 1
          [subtotal_harga] =&gt; 25905
      )
  
  [1] =&gt; Array
      (
          [kode_pbt] =&gt; PBT3-2012-10-19
          [kodebr] =&gt; 8992388112401
          [harga] =&gt; 1340.00
          [jml] =&gt; 1
          [subtotal_harga] =&gt; 1340
      )
  
    )
  </code></pre>
  
  <p>my problem is when i want to insert to database 
  white this code : $this->db->insert($table, $data)
  i got an error:
  Message: Array to string conversion
  I have changed to $this->db->insert_batch($table, $data), but i got error '500 internal server error'.
  Thank for your assist.</p>
  
  <p>This is my full function code in controller :</p>
  
  <pre><code>function save_pbt($kode = -1) {
      $pbt_detail = array();
      $pbt_data = array(
          'kode_pbt' =&gt; trim($this-&gt;input-&gt;post('kode_pbt')),
          'unit_pemakai' =&gt; trim($this-&gt;input-&gt;post('unit_pemakai')),
          'jml_item' =&gt; trim($this-&gt;input-&gt;post('jml_item')),
          'total_harga' =&gt; trim($this-&gt;input-&gt;post('total_harga')),
          'tgl_pbt' =&gt; date('Y-m-d'),
          'status' =&gt; 0
      );
      for ($i = 0; $i &lt;= $this-&gt;input-&gt;post('max_i'); $i++) {
          if ($this-&gt;input-&gt;post('kodebr' . $i)) {
              $detail_pbt = array(
                  'kode_pbt' =&gt; $this-&gt;input-&gt;post('kode_pbt'),
                  'kodebr' =&gt; $this-&gt;input-&gt;post('kodebr' . $i),
                  'harga' =&gt; $this-&gt;input-&gt;post('beli' . $i),
                  'jml' =&gt; $this-&gt;input-&gt;post('jml' . $i),
                  'subtotal_harga' =&gt; $this-&gt;input-&gt;post('subtotal' . $i)
              );
              array_push($pbt_detail, $detail_pbt);
          }
      }
  
  
      $this-&gt;db-&gt;trans_begin();
      $this-&gt;Pbt_model-&gt;insert_pbt($pbt_data);
      $this-&gt;Pbt_model-&gt;insert_detail_pbt($pbt_detail);
      if ($this-&gt;db-&gt;trans_status() == FALSE) {
          $this-&gt;db-&gt;trans_rollback();
  
          echo "TRANSACTION ROLLBACK";
      } else {
          $pbt_data['detail'] = $pbt_detail;
          $url = SERVER_SIKOPIT . 'service/service?process=pbt&amp;api_key=' . API_KEY;
          $response = json_encode($this-&gt;rest_helper($url, $pbt_data, "POST"));
          echo $response;
          $response = json_decode($response);
          if ($response-&gt;status == true) {
              $this-&gt;db-&gt;trans_commit();
              echo "TRANSACTION SUCCESS";
              redirect(site_url('receivings'));
          } else {
              $this-&gt;db-&gt;trans_rollback();
              echo "INSERT PBT BARU GAGAL !!";
              echo "TRANSACTION ROLLBACK";
          }
      }
  }
  </code></pre>