If you get the (possibly generated) SQL code, you could examine the number of inserts to be done by parsing the statement with a regular expression.
Another approach is to define a trigger. In this case you have to set a user defined variable before the execution of the statement and read it via another query after the execution.
CREATE TRIGGER `beforeUpdateTABLENAME`
BEFORE UPDATE ON `tablename` FOR EACH ROW
SET @updateRowCount = @updateRowCount + 1;
Reset row count
$connection->exec('SET @updateRowCount = 0;');
Execute the INSERT ... ON DUPLICATE KEY UPDATE ...
and read the number of updates
$result = $conn->query('SELECT @updateRowCount;');
Calculate rows affected = row count - updated rows
If you do not want to distinguish between inserts and updates at all, you can trigger on INSERT as well and no calculation is needed.
CREATE TRIGGER beforeInsertTABLENAME
BEFORE INSERT ON `tablename` FOR EACH ROW
SET @rowsAffectedCount = @rowsAffectedCount + 1;