confirm batchinsert success

Hi

I couldn’t work out how to confirm the success or failure of a BatchInsert() method.

$connection->createCommand()->batchInsert(‘user’, [‘name’, ‘age’], [

['Tom', 30],


['Jane', 20],


['Linda', 25],

])->execute();

The docs say that it returns the command object itself, so how would I confirm success or display errors?

Thanks

documentation

The batchInsert() method indeed returns the command itself however the next chained method execute() executes the command and returns “Number of rows affected by the execution.” or throws exception in case of failure. That’s what Pasman pointed out.