CodeIgniter Forums

Full Version: Inserting multiple rows in Codeigniter
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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?
Why do you think it's not efficient?