php - A more efficient way of saving 125 columns in a Laravel controller -


i have rather large table has 125 data inputs, each of has saved in separate column.

i have named each html input 1,2,3 etc... , same within table, things.

at moment, have following code:

$observation = new observation(); $observation->site_id = input::get('site_id'); $observation->result = input::get('1'); $observation->result_id = '1'; $observation->save(); 

is there way use loop iterate through 125 data inputs (input::get('x') , result_id = 'x') , save them all?

for($i=1; $i<=125; $i++) {      $data[$i] = [         'site_id'=>input::get('site_id'),         'result'=>input::get($i), 'result_id'=>$i     ]; } 

using query builder:

db::table('table')->insert($data); // change table name.  

and if want use eloquent:

model::insert($data); 

Comments

Popular posts from this blog

java - pagination of xlsx file to XSSFworkbook using apache POI -

Unlimited choices in BASH case statement -

apache - How do I stop my index.php being run twice for every user -