php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #38103 PDO::FETCH_INTO fails w/extraneous param
Submitted: 2006-07-14 10:12 UTC Modified: 2006-07-18 23:04 UTC
From: jeffmlevy+phpbugs at gmail dot com Assigned: wez (profile)
Status: Not a bug Package: PDO related
PHP Version: 5.1.4 OS: Debian GNU Linux
Private report: No CVE-ID: None
 [2006-07-14 10:12 UTC] jeffmlevy+phpbugs at gmail dot com
Description:
------------
Note: Mysql PDO.

PDO fails with error when calling fetchAll() w/PDO::FETCH_INTO.

Implicit call to setFetchMode(PDO::FETCH_INTO, $oObject) passes the test, however.

Reproduce code:
---------------
$stmt = $dbh->prepare("call data_loader()");

$stmt->setFetchMode(PDO::FETCH_INTO, $this);
$stmt->fetchAll();

results in proper assignment of return vars to object props.

BUT:

$stmt = $dbh->prepare("call data_loader()");
$stmt->fetchAll(PDO::FETCH_INTO, $this);

calling with $this results in: 
     PDOStatement::fetchAll(): SQLSTATE[HY000]: General error: Extraneous additional parameters


calling without $this results in 
    PDOStatement::fetchAll(): SQLSTATE[HY000]: General error: No fetch-into object specified.

Expected result:
----------------
Expect class properties to be properly populated.

Actual result:
--------------
Error thrown.

Could be lack of documenatation??

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-07-14 12:01 UTC] wez@php.net
RTM.  At no point does it tell you that you can use FETCH_INFO with fetchAll().  Think about what that means.
 [2006-07-17 21:07 UTC] jeffmlevy+phpbugs at gmail dot com
I wholeheartedly apologize. I meant "fetch()", not fetchAll().

This issue applies to $stmt->fetch(PDO::FETCH_INTO, $this)

Thank you.
 [2006-07-18 23:04 UTC] jeffmlevy+phpbugs at gmail dot com
sovled:

$stmt = $this->dbh->query("call load($data_id)",, PDO::FETCH_INTO, $this);
$stmt->fetch();


wez, can I have your baby? rule.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 23 12:01:31 2024 UTC