php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #38433 Error with aggregate MySQL functions
Submitted: 2006-08-11 21:57 UTC Modified: 2006-08-22 01:00 UTC
Votes:3
Avg. Score:3.7 ± 0.9
Reproduced:3 of 3 (100.0%)
Same Version:1 (33.3%)
Same OS:0 (0.0%)
From: tichy at livada dot cz Assigned:
Status: No Feedback Package: PDO related
PHP Version: 5CVS-2006-08-11 (snap) OS: Linux
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2006-08-11 21:57 UTC] tichy at livada dot cz
Description:
------------
Getting PDO exception (SQLSTATE[HY000]: General error: 2036) when using aggregate function on PHP5 via PDO and MySQL5. (No problem when using MySQL4 or without PDO).

PHP 5.2.0RC2-dev
MySQL 5.0.19





Reproduce code:
---------------
// MySQL

CREATE TABLE `test` (
  `ids` int(11) NOT NULL,
  `value` int(11) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

-- 
-- Dumping data for table `test`
-- 

INSERT INTO `test` VALUES (10, 23);
INSERT INTO `test` VALUES (10, 13);

// PHP


$query = 'SELECT AVG(value) FROM test WHERE ids=10 GROUP BY ids';

$dbh = new PDO($dsn, $user, $password);
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$rs = $dbh->query($query);
$result = $rs->fetchAll(PDO::FETCH_ASSOC);
print_r($result);

Expected result:
----------------
Array
(
    [0] => Array
        (
            [AVG(value)] => 18.0000
        )

)


Actual result:
--------------
Fatal error:  Uncaught exception 'PDOException' with message 'SQLSTATE[HY000]: General error: 2036

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-08-14 09:32 UTC] tony2001@php.net
Can't reproduce with 5.2-CVS and MySQL 5.0.21.
 [2006-08-22 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Apr 29 22:01:28 2024 UTC