I'd like to perform the following query:
(SELECT COUNT(*) FROM `tab2` WHERE `parent` = :id) AS `sum`
WHERE `id` = :id
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY093]: Invalid parameter number
PDO::prepare states that
[y]ou cannot use a named parameter marker of the same name more than once in a prepared statement, unless emulation mode is on.
Since it's generally better to leave emulation mode off (so the database does the prepared statement), you'll have to use