>
> Select * From products Where product_id = 'hello world'
>
> If product_id is a column of type int, then the database will raise an
> error about incompatible types.
>

No, this query would produce a warning. I am unaware of an SQL mode that
would turn this warning into an error. Maybe I am wrong and there is a way
to convert this into an error, but that would be pointless.
I believe you have chosen the wrong example. That query, even when executed
with PDO, doesn't throw an exception.

The point of this RFC is that mysqli should treat SQL errors the same way
that PDO does. By default, all errors should be reported. An error in SQL
is the same as an exception in PHP code; it means that something went
terribly wrong. I have been using PDO for a few years now and I never had a
need to silence its error reporting. SQL doesn't spit out exceptions
randomly.

Examples, that would truly be effected are something like this:

$stmt = $mysqli->query('INSERT INTO tableA (uniqueColumn) VALUE("repeated
value")');
if (1062 === $mysqli->errno) {
    echo "Can't add this value because it already exists!";
}

If the developer didn't silence the errors then the user will see a generic
error instead of the specific one.

Reply via email to