Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pass multiple parameters on Laravel 4 DB::transaction()?

Tags:

php

I am trying this:

  $iddocente = '1';
  $idcurso = '2';
  DB::transaction(function() {
    DB::table('users')->insert(
      array('docente' => $iddocente, 'curso' => $idcurso)
    );
  });

But no work. Help me please.

like image 634
Sunday Avatar asked Jan 28 '14 20:01

Sunday


1 Answers

The use keyword is what you want.

DB::transaction(function() use ($iddocente, $idcurso) {
like image 110
ceejayoz Avatar answered Oct 20 '22 03:10

ceejayoz