|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #79272 Add PDO::ATTR_EMULATE_PREPARES support for SQLite
Submitted: 2020-02-13 19:45 UTC Modified: -
Avg. Score:3.0 ± 0.0
Reproduced:2 of 2 (100.0%)
Same Version:1 (50.0%)
Same OS:0 (0.0%)
From: effulgentsia1 at gmail dot com Assigned:
Status: Open Package: PDO SQLite
PHP Version: Next Minor Version OS: All
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
Solve the problem:
13 - 12 = ?
Subscribe to this entry?

 [2020-02-13 19:45 UTC] effulgentsia1 at gmail dot com
MySQL and PostgreSQL have limits of 65535 placeholders for native prepared statements. However, if more are passed, the PDO drivers fallback to emulating prepares, in which case the only limit is whatever the database server has configured for its SQL statement length limit (e.g., max_allowed_packet for MySQL).

However, SQLite has a default limit of 999 placeholders (, and the PDO driver for it does not fallback to emulating prepares, or support the PDO::ATTR_EMULATE_PREPARES at all.

For Drupal, we use PDO and support MySQL, PostgreSQL, and SQLite. For consistency, it would be helpful if the PDO driver for SQLite also supported emulated prepares.

Test script:
Same as in


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2021-03-25 01:04 UTC] apostnikov at gmail dot com
Used to confirm the bug on PHP 8.0.3 with sqlite builded with limit 250000

script is
$large_array = range(0, 250001);

$db = new PDO('sqlite::memory:');
$placeholders = implode(', ', array_fill(0, count($large_array), '?'));
$stmt = $db->prepare("SELECT 1 WHERE 42 IN ($placeholders)");

PHP Fatal error:  Uncaught Error: Call to a member function execute() on bool in /mnt/a.php:7
Stack trace:
#0 {main}
  thrown in /mnt/a.php on line 7

Fatal error: Uncaught Error: Call to a member function execute() on bool in /mnt/a.php:7
Stack trace:
#0 {main}
  thrown in /mnt/a.php on line 7
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Mon Sep 27 07:03:36 2021 UTC