How to prevent PDO from interpreting a question mark as a placeholder?

Use the function call form. According to the system catalogs, the hstore ? operator uses the exist function:

regress=# select oprname, oprcode from pg_operator where oprname = '?';
 oprname | oprcode 
---------+---------
 ?       | exist
(1 row)

so you can write:

SELECT * FROM tbl WHERE exist(hst,'foo');

(Personally I'm not a big fan of hstore's operator-centric design and documentation, I think it discards the useful self-documenting properties of a function based interface without any real benefit and I usually use its function calls rather than its operators. Just because you can define operators doesn't mean you should.)


I had the same problem when searching on JSONB data. The full question is here

SELECT * FROM post WHERE locations ? :location;

The workaround on PostgreSQL 9.5 is similar:

SELECT * FROM post WHERE jsonb_exists(locations, :location);

I also opened a ticket at PHP bug tracing system

Update

As Diabl0 mentioned, the proposed solution work but does not use the index. Tested with:

CREATE INDEX tempidxgin ON post USING GIN (locations);