i have a sql query in Zend Framework 2. It works great, but i forgot to escape my $sessionId, just to protect my variable so that nobody can inject my SQL query. Here is my sql Query:
SELECT parent.category_name, parent.category_id ,COUNT(product.product_id) AS count,
(select count(*) from Categories parent2
where parent.category_left > parent2.category_left
and parent.category_right < parent2.category_right) as level
FROM Categories parent
LEFT OUTER JOIN Categories node
ON node.category_left BETWEEN parent.category_left AND parent.category_right
LEFT OUTER JOIN products product
ON node.category_id = product.product_category_id
WHERE product.product_shop_id = '.$sessionId.'
GROUP BY parent.category_name
ORDER by node.category_left;
I've could wrote it in a Zend $select object, with this Zend would have escaped it by himself. Is there any way to escpae this variable by using this sql query? (I tried also mysql_real_escape_string(), but i've read this function is to old to use it.
Greetings =)