DB2, E_ALL and SQLCODE=100
I am currently working on a DB2 instance on IBM i (AS400), and just upgraded to doctrine/dbal 3… and guess what? It did not work out of the box!
First thing to do: jump on a very simple case, say a findBy
in a simple repository, and dig in to debug. The error message is:
Warning: db2_stmt_error(): La ligne n'a pas {t{ trouv{e pour C65399500002000003. SQLCODE=100
Sorry for the French above… It roughly translates to:
NOT FOUND: ROW NOT FOUND FOR FETCH, UPDATE, OR DELETE, OR THE RESULT OF A QUERY IS AN EMPTY TABLE
Digging in the codebase, I ended up finding that the db2_stmt_error from vendor/doctrine/dbal/src/Driver/IBMDB2/Result.php
is not silenced, hence the warning.
Adding the @
character before the db2_stmt_error
does the trick (silencing the warning).
In order to reproduce this bug, you’d need to be in a E_ALL error_reporting mode too.
If you’re interested, here is a PR to solve this specific problem: https://github.com/doctrine/dbal/pull/5162