PHPize Online / SQLize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
CREATE TABLE test ( id INT AUTO_INCREMENT, name VARCHAR(100), PRIMARY KEY (id) );
Copy Clear
Copy Format Clear
<?php $array = [ [1, 'Chad'], [4, 'Ned'], [5, 'Dave'], [14, 'Newt'], [18, 'Bill'], [21, 'Norton'], [25, 'Alan'], ]; $sql = sprintf( 'INSERT INTO test (id, name) VALUES (%s)', implode('),(', array_fill(0, count($array), '?,?')) ); $mysqli->execute_query($sql, array_merge(...$array)); var_export( $mysqli->query('SELECT * FROM test')->fetch_all(MYSQLI_ASSOC) );
Show:  
Copy Clear