BEFORE:
see #2388255: (followup) Limit PDO MySQL to executing single statements if PHP supports it
Protection against executing multiple SQL statements was only available when running more recent PHP versions and only for MySQL.
AFTER:
The base DB code checks all SQL strings and throws an exception if a delimiter (a ";" character) is present. This should not cause any problems if all user data is interpolated via placeholders.
The only other case case it may cause problems is when creating stored procedure. For example for postgres:
if (!$connection->query("SELECT COUNT(*) FROM pg_proc WHERE proname = 'substring_index'")->fetchField()) {
$connection->query('CREATE OR REPLACE FUNCTION "substring_index"(text, text, integer) RETURNS text AS
\'SELECT array_to_string((string_to_array($1, $2)) [1:$3], $2);\'
LANGUAGE \'sql\'',
[],
[ 'allow_delimiter_in_query' => TRUE ]
);
}
For these rare cases, there is a new option for the query method (as shown) [ 'allow_delimiter_in_query' => TRUE ]. If you set this option to TRUE, then you get the prior behavior which is that for recent PHP version MySQL version will still be protected, but other drivers will not be.
Not that this PHP-land check is not actually parsing the SQL, so the example creation of a stored procedure is a single statement (so would be fine with the native protection) but causes an incorrect fail with the delimiter check.