PHPize Online / SQLize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
Copy Clear
Copy Format Clear
<?php $mysqli->query("create table t(i int)"); $data = [ range(1,3), range(4,6), range(7,9), ]; $sql = "INSERT INTO t (col1,col2,col3) VALUES "; $values = "(?".str_repeat(",?",count($data[0])-1).")"; // (?,?,?) $sql .= $values.str_repeat(",$values",count($data)-1); // (?,?,?),(?,?,?) $stmt = $mysqli->prepare($sql); $types = str_repeat("s", count($data) * count($data[0])); // sss $params = array_merge(...$data); $stmt->bind_param($types, ...$params); $stmt->execute(); echo $mysqli->affected_rows;
Show:  
Copy Clear