mysql - In PHP, when I use $dbh->prepare($query)->execute($values) with placeholders, how can I INSERT multiple records one time? -
$dbh = new pdo($dsn, $username, $password); $query = 'insert `table1` (`id`, `name`) values (?, ?)'; $values = [ [1, 'mary'], [2, 'peter'], [3, 'mike'] ]; $stmt = $dbh->prepare($query); $stmt->execute($values);
i know above codes cause errors. if want insert multiple records placeholders conveniently, how can do?
@cbroe has provided answers question. please refer above comments, , refer link posted, has more detailed discussions within it.
Comments
Post a Comment