I use PHP and MySQL with PDO. Sometimes I need to prepare a statement with one variable (placeholder) used more than once in this query.
Example:
SELECT * FROM messages WHERE from_id = :user OR to_id = :user
However, if I try to prepare this statement, I will have an error, so I need to do this as follows:
SELECT * FROM messages WHERE from_id = :user1 OR to_id = :user2
To call this statement, I will need to have an array like this:
array('user1'=>$user_id, 'user2'=>$user_id);
It looks so stupid for me! Why does MySQL (PDO?) Prevent me from using one place holder more than once and forcing me to use additional variables that require more control ?!
, (, ), 5 (!!!) . , , , .
- ?