• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
insert_batch not insert data

#1
Hi all,
I'm new to code igniter but I love it Smile
I have issue with insert_batch, when I try to save multiple row the script no save data

The array:

Code:
Array ( [0] => Array ( [company_name] => thename0 ) [1] => Array ( [company_name] => thename1 ) [2] => Array ( [company_name] => thename2 ) [3] => Array ( [company_name] => thename3 ) )


The controller:

PHP Code:
       public function index()
 
       {
 
               $this->load->helper('file');
 
               $json read_file('./myfile.json');
 
               $obj json_decode($json);
 
               $data['json'] = $obj;
 
               foreach ($data['json']->res as $val
 
               {
 
                       $batch[] = array(
 
                                       'company_name' => $val->res->company_name
                                        
                                
);
 
               }
 
               $this->my_model->get_json_file($batch);

 
       


The model:

PHP Code:
   public function __construct()
 
   {
 
           $this->load->database();
 
   }
 
   public function get_json_file($data)
 
     
        $this
->db->insert_batch('my_table'$data);
 
   


I have not error message in the page but data not present in the DB.


Confused
Reply

#2
Does just insert work?

Do you have a Primary Key in your table and if it set to Auto Increment?
Reply

#3
@ven0m,

Have you looked at the log file to see if any errors are there?
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.