This is my query:
$last = count($list)-1;
$sql = 'INSERT INTO table (col1, col2, col3) VALUES ';
for($i=0; $i<$last; $i++) {
    $sql .= '("'. $list[$i]['col1'] .'", "'. $list[$i]['col2'] .'", '. $list[$i]['col3'] .'), ';
}
$sql .= '("'. $list[$last]['col1'] .'", "'. $list[$last]['col2'] .'", '. $list[$last]['col3'] .') ';
$sql .= 'ON DUPLICATE KEY UPDATE ';
for($i=0; $i<$last; $i++) {
    $sql .= 'col3 = '. $list[$i]['col3'] .', ';
}
$sql .= 'col3 = '. $list[$last]['col3'];
DB::statement($sql);
Query without PHP:
INSERT INTO table (col1, col2, col3) VALUES
    ( $list[$i]['col1'] , $list[$i]['col2'] , $list[$i]['col3'] ),
    ...
    ( $list[$i]['col1'] , $list[$i]['col2'] , $list[$i]['col3'] )
ON DUPLICATE KEY UPDATE
    col3 = $list[$i]['col3'],
    ...
    col3 = $list[$i]['col3'];
I've looked at this and this. It's somewhat unclear to me how I should be doing it. Am I supposed to do it like this?
DB::connection()->getPdo()->quote($sql);
I've also read you can do something along these lines:
DB::escape($sql)
What is the best and easiest way to prevent SQL injection for the above query using Laravel?
array(1, 'Dayle')to a variable, initialize it as an array before your query and push the values you want added into it (in the correct order).?and instead push the variables into an array that you later send into theDB::insertmethod.