I have recently started using PDO as I understand it's a 1000 times better for security, etc. Imagine my surprise when I find out that the majority of my queries are not working. After much teeth gnashing, I find that the problem lies in the fact that PDO doesn't seem to like parameters anywhere but in the WHERE clause. Take this example.
// ... blah blah, connection
$params = array(
':gallery_id' => 1,
'page_offset' => 0,
'page_limit' => 25
);
$sql = "SELECT * FROM gallery WHERE gallery_id = :gallery_id LIMIT :page_offset, :page_limit";
// ... do query stuff here with PDO
No dice. If I do the following, it works:
$sql = "SELECT * FROM gallery WHERE gallery_id = :gallery_id LIMIT 0, 25";
I also noticed that PDO doesn't seem to like taking field names for ORDER BY clauses.
So am I stuck with having to use mysql_real_escape_string() for variables that need to be put in anywhere other than the where clause? This seems a bit counter productive.