• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Inserting multiple rows in Codeigniter

#1
I need to insert mutliple rows in codeigniter 3 with a single query. Now I'm currently using insert_batch and formatting the insert data as follows:



Code:
        $user_privileges = array (
            array (
                'user_level_id' => $usr_level_id,
                'privilege_id'  => '501'
            ),
            array (
                'user_level_id' => $usr_level_id,
                'privilege_id'  => '505'
            ),
            array (
                'user_level_id' => $usr_level_id,
                'privilege_id'  => '520'                
            )
        );




Which works fine, but doesnt seem very efficient to me. What if I had 500 rows etc, whats an easier way to do it?
Reply

#2
Why do you think it's not efficient?
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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