|   | php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
| 
  [2006-04-22 15:30 UTC] troelskn at gmail dot com
 Description: ------------ Using PDO::FETCH_FUNC with fetchAll() only works with a function. It would be nice if it worked with a normal callback type (as in call_user_func and others). If this can't be fixed, the error message must be changed, since "General error: user-supplied function must be a valid callback" is misleading. PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits             | |||||||||||||||||||||||||||
|  Copyright © 2001-2025 The PHP Group All rights reserved. | Last updated: Fri Oct 31 01:00:01 2025 UTC | 
Reproduce code: --------------- <?php class Test { protected $connection; function __construct() { $this->connection = new PDO("sqlite::memory:"); $this->connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $this->connection->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER); $this->connection->query("CREATE TABLE test (a integer primary key)"); $this->connection->query("INSERT INTO test VALUES (22)"); } function select() { $query = "SELECT * FROM test"; $result = $this->connection->query($query); return $result->fetchAll(PDO::FETCH_FUNC, Array($this, 'loadRecord')); } function loadRecord($row) { return new ArrayObject($row); } } $test = new Test(); var_dump($test->select()); ?> Expected result: ---------------- no error Actual result: -------------- Apache crashes.