Looking at thegeneral
MySQL log, when I use mysqli
with parameterized queries with PHP I see statements like this:
Prepare SELECT * FROM my_table WHERE id = ?
Execute SELECT * FROM my_table WHERE id = 9
Prepare INSERT INTO my_table SET name = ?
Execute INSERT INTO my_table SET name = 'Alex'
This makes me feel warm and fuzzy, because I distinctly see that first, my query was sent, and them, my parameters, in two separate statements.
But when using an ORM (Doctrine in this case), I see the following:
Query SELECT t0.id AS id_1, t0.name AS name_2 FROM my_table t0 WHERE t0.id = '9'
Query START TRANSACTION
Query INSERT INTO my_table (name) VALUES ('Alex')
Query COMMIT
This has me feel alerted, as I do not see the same sequence of statement being send followed by parameters. It's statement + parameters in one go.
Questions about this that I have are:
- Is Doctrine actually using parameterized statements, and why doesn't it do what MySQL does - log two packets, like
mysqli
does natively? - Is Doctrine safe from injection attacks in whatever it is doing now?
- How is Doctrine safe from attacks, when it lumps statement and parameters into the same single query, per query? Does it really do something else here?