php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #56310 PDO/MySQL getColumnMeta() broken
Submitted: 2005-02-20 06:08 UTC Modified: 2005-02-20 18:56 UTC
From: thekid@php.net Assigned: hholzgra (profile)
Status: Closed Package: PDO_MYSQL (PECL)
PHP Version: 5_1 CVS-2005-02-20 (dev) OS:
Private report: No CVE-ID: None
 [2005-02-20 06:08 UTC] thekid@php.net
Description:
------------
PDO/MySQL getColumnMeta() always returns bool(false) in pdo_mysql due to a bogus check

Reproduce code:
---------------
the following sourcecode:

<?php
  $dbh= new PDO('mysql:host='.$argv[1], $argv[2], $argv[3]); 

  $stmt= $dbh->prepare('select * from entries where id = :id');
  $stmt->bindParam(':id', $argv[4]);
  if (!$stmt->execute()) {
    var_dump($dbh->errorInfo());
    exit;
  }

  for ($i= 0, $s= $stmt->columnCount(); $i < $s; $i++) {
    echo $i, ':: '; var_dump($stmt->getColumnMeta($i));
  }
?>

Expected result:
----------------
0:: array(6) {
  ["native_type"]=>
  string(4) "LONG"
  ["flags"]=>
  array(2) {
    [0]=>
    string(8) "not_null"
    [1]=>
    string(11) "primary_key"
  }
  ["name"]=>
  string(2) "id"
  ["len"]=>
  int(11)
  ["precision"]=>
  int(0)
  ["pdo_type"]=>
  int(2)
}
1:: array(6) {
  ["native_type"]=>
  string(10) "VAR_STRING"
  ["flags"]=>
  array(0) {
  }
  ["name"]=>
  string(5) "title"
  ["len"]=>
  int(200)
  ["precision"]=>
  int(0)
  ["pdo_type"]=>
  int(2)
}
[...and so on...]

Actual result:
--------------
1:: bool(false)
2:: bool(false)
[...and so on...]


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-02-20 06:15 UTC] thekid@php.net
Patch that fixes this issue:

  http://sitten-polizei.de/pdo_mysql.diff

(also fixes #3530)

Note: I removed the comment reading

  /* FIXME where does this get freed? */

because the column name is freed in pdo_stmt.c in free_statement()
 [2005-02-20 18:56 UTC] hholzgra@php.net
This bug has been fixed in CVS.

In case this was a documentation problem, the fix will show up at the
end of next Sunday (CET) on pecl.php.net.

In case this was a pecl.php.net website problem, the change will show
up on the website in short time.
 
Thank you for the report, and for helping us make PECL better.


 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Sat Sep 19 17:01:25 2020 UTC