Weird PDO issue

Sic

Sic

Soldato
Joined
9 Nov 2004
Posts
15,365
Location
SO16
I'm sure this is something obvious, but I've been through the documentation and I can't find anything. I'm having a problem with PDO where if I use the same variable twice in a query, it only uses the first one. Example:

PHP:
$this->stm = $this->db->prepare(
  'SELECT * FROM Sample WHERE foo = :col OR bar = :col'
);
$this->stm->execute(array('col' => 1));

It's completely ignoring the "bar = :col" part and, as such, is returning no results (also no errors, and I can't seem to make it fall over). I can solve this by changing the query to WHERE foo = :col1 and bar = :col2 but I'm not a huge fan of doing that when I shouldn't have to (works fine on my local setup, but not my test setup, which is fedora, if that helps.

Does anyone know of anything that might be causing this?
 
Back
Top Bottom