|   | php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
| 
  [2016-03-23 09:16 UTC] miki at epoch dot co dot il
 Description: ------------ When I prepare the following query: SELECT * FROM post WHERE locations ? :location; The following warning occur: Warning: PDO::prepare(): SQLSTATE[HY093]: Invalid parameter number: mixed named and positional parameters in /path/file.php on line xx The question mark is an valid PostgreSQL operator but PDO condsider it as a placeholder. - http://www.postgresql.org/docs/9.5/static/functions-json.html I thought of several solutions: 1. Allow to disable question mark as placeholder. Leaving you with named placeholders. 2. Allow to change the placeholder char from a default value (?). 3. Teach pg driver to distinguish when it is a placeholder or an operator. I think I favor point 2. I also discussed it here: http://stackoverflow.com/questions/36173440/how-to-ignore-question-mark-as-placeholder-when-using-pdo-with-postgresql PatchesPull Requests
Pull requests: 
 HistoryAllCommentsChangesGit/SVN commits             | |||||||||||||||||||||||||||||||||||||
|  Copyright © 2001-2025 The PHP Group All rights reserved. | Last updated: Fri Oct 31 18:00:01 2025 UTC | 
Hi Requinx, The following code failed: $sql = "SELECT * FROM post WHERE locations ? :location ORDER BY locations->:location" $pdo->setAttribute(\PDO::ATTR_EMULATE_PREPARES ,false); $stmt = $pdo->prepare($sql); // tried this and version bellow $stmt = $pdo->prepare($sql, [\PDO::ATTR_EMULATE_PREPARES=>false]); $stmt->bindValue(':location', 'bar', \PDO::PARAM_STR); $stmt->execute(); Error when ATTR_EMULATE_PREPARES is false that happen at the line of the prepare(): Warning: PDO::prepare(): SQLSTATE[HY093]: Invalid parameter number: mixed named and positional parameters in /path/file.php on line 57 Error when ATTR_EMULATE_PREPARES is true that happen at the line of the execute(): Warning: PDOStatement::execute(): SQLSTATE[HY093]: Invalid parameter number: mixed named and positional parameters in /path/file.php on line 48 Any idea?