Using Yii2 advanced app with sqlsrv PDO driver v5.9, when inserting multiple strings. There is an error when a string with a trailing slash is put before a string with a question mark if there is also a string with a colon followed by text. In this example, if you put the line with the trailing slash after the line with the question mark it works fine, also if you remove one of either the trailing slash, or question mark, or colon it will work fine as is. I have tried escaping the characters with backslashes and it made no difference.
PDO Errors:
Caused by: Exception 'PDOException' with message 'SQLSTATE[IMSSP]: An error occurred substituting the named parameters.'
Caused by: Exception 'PDOException' with message 'SQLSTATE[HY093]: Invalid parameter number: mixed named and positional parameters'
DOES NOT WORK
$sql = "INSERT INTO test (description) VALUES
('test with a trailing slash\'),
('test with a question mark?'),
('test with :colon')";
Yii::$app->db->createCommand($sql)->prepare();
WORKS
$sql = "INSERT INTO test (description) VALUES
('test with a question mark?'),
('test with a trailing slash\'),
('test with :colon')";
Yii::$app->db->createCommand($sql)->prepare();
WORKS
Removing either of the 3 characters (\, ?, :) works
$sql = "INSERT INTO test (description) VALUES
('test with a question mark'),
('test with a trailing slash\'),
('test with :colon')";
Yii::$app->db->createCommand($sql)->prepare();