return $this->connection->
query($sql,
$this->fromQuery->
getArguments(),
$this->queryOptions
);
} $last_insert_id = 0;
$stmt =
$this->connection->
prepareStatement((string) $this,
$this->queryOptions
);
try { // Per https://en.wikipedia.org/wiki/Insert_%28SQL%29#Multirow_inserts,
// not all databases implement SQL-92's standard syntax for multi-row
// inserts. Therefore, in the degenerate case, execute a separate query
// for each row, all within a single transaction for atomicity and
// performance.
$transaction =
$this->connection->
startTransaction();
foreach ($this->insertValues
as $insert_values) { $stmt->
execute($insert_values,
$this->queryOptions
);
$last_insert_id =
$this->connection->
lastInsertId();
} } catch (\Exception
$e) { if (isset($transaction)) { // One of the INSERTs failed, rollback the whole batch.
$transaction->
rollBack();
} // Rethrow the exception for the calling code.