php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #56565 PDO_OCI doesn't support getColumnMeta()
Submitted: 2005-09-28 20:28 UTC Modified: 2005-09-30 08:45 UTC
Votes:4
Avg. Score:4.5 ± 0.9
Reproduced:4 of 4 (100.0%)
Same Version:1 (25.0%)
Same OS:2 (50.0%)
From: gogala at sbcglobal dot net Assigned:
Status: Suspended Package: PDO_OCI (PECL)
PHP Version: Irrelevant OS: Linux, FC3
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: gogala at sbcglobal dot net
New email:
PHP Version: OS:

 

 [2005-09-28 20:28 UTC] gogala at sbcglobal dot net
Description:
------------
PDO_OCI 1.0RC1 gives the following error:

PHP Warning:  PDOStatement::getColumnMeta(): SQLSTATE[IM001]: Driver does not support this function: driver doesn't support meta data in /home/mgogala/tmp/test_pdo.php on line 13

PHP version is:
$ php -v
PHP 5.0.5 (cli) (built: Sep 28 2005 19:53:07)
Copyright (c) 1997-2004 The PHP Group
Zend Engine v2.0.5, Copyright (c) 1998-2004 Zend Technologies
$

Also, an exception is not thrown, except in the case of an 
incorrect password.

Reproduce code:
---------------
#!/usr/local/bin/php
<?php
    $SQL1="select * from emp where ename like :ENAME";
    $name='%';
    try {
        $dbh = new PDO("oci:dbname=local", "scott", "tiger");
        $sth=$dbh->prepare($SQL1);
        $sth->bindParam(":ENAME",$name,PDO_PARAM_STR,100);
        $sth->execute();
        $cnt=$sth->columnCount();
        echo "This statement returns ",$cnt, " columns\n";
        for($i=0;$i<$cnt;$i++) {
           print_r($sth->getColumnMeta($i));
           print("\n");
        }

    } catch (PDOException $e) {
        echo "Failed to obtain database handle " . $e->getMessage(),"<br>\n";
    }
?>
$


Expected result:
----------------
Self evident

Actual result:
--------------
$ test_pdo.php
This statement returns 8 columns
PHP Warning:  PDOStatement::getColumnMeta(): SQLSTATE[IM001]: Driver does not support this function: driver doesn't support meta data in /home/mgogala/tmp/test_pdo.php on line 13

PHP Warning:  PDOStatement::getColumnMeta(): SQLSTATE[IM001]: Driver does not support this function: driver doesn't support meta data in /home/mgogala/tmp/test_pdo.php on line 13

PHP Warning:  PDOStatement::getColumnMeta(): SQLSTATE[IM001]: Driver does not support this function: driver doesn't support meta data in /home/mgogala/tmp/test_pdo.php on line 13

PHP Warning:  PDOStatement::getColumnMeta(): SQLSTATE[IM001]: Driver does not support this function: driver doesn't support meta data in /home/mgogala/tmp/test_pdo.php on line 13

PHP Warning:  PDOStatement::getColumnMeta(): SQLSTATE[IM001]: Driver does not support this function: driver doesn't support meta data in /home/mgogala/tmp/test_pdo.php on line 13

PHP Warning:  PDOStatement::getColumnMeta(): SQLSTATE[IM001]: Driver does not support this function: driver doesn't support meta data in /home/mgogala/tmp/test_pdo.php on line 13

PHP Warning:  PDOStatement::getColumnMeta(): SQLSTATE[IM001]: Driver does not support this function: driver doesn't support meta data in /home/mgogala/tmp/test_pdo.php on line 13

PHP Warning:  PDOStatement::getColumnMeta(): SQLSTATE[IM001]: Driver does not support this function: driver doesn't support meta data in /home/mgogala/tmp/test_pdo.php on line 13


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-09-30 00:40 UTC] wez@php.net
getColumnMeta is not a stable feature of PDO and won't be until a later release.
As for throwing exceptions, consult the PDO documentation on error handling.
 [2005-09-30 01:10 UTC] gogala at sbcglobal dot net
So, how do I find out about the column name, type and length?
That makes the present PDO_OCI driver practically useless.

Also, where can I find any documentation? The one on PHP main site is obviously hopelessly outdated.
 [2005-09-30 08:45 UTC] wez@php.net
The column name, if you really need to know it, is available as part of the associative keys that you get back when using the PDO::FETCH_ASSOC mode.

The php data type will usually be a string unless you asked the driver to bind it differently.  Usually, you know what data types you're fetching from the database, and can use PHP functions and casts to manipulate the results to suit.

Similarly, the length of the columns is unimportant in a dynamic language like PHP.

The majority of applications honestly don't need getColumnMeta.  Those that do are usually the type of application that wants to do some kind of DBA tasks, and since those need to know how to query and alter the structure of the database using native queries, they don't really need getColumnMeta either.

Hmm, looks like the main docs site hasn't been rebuilt for a couple of weeks.  Caveat emptor: The docs at docs.php.net reflect the next release of PDO, where PDO_FETCH_MODE style constants have been changed to PDO::FETCH_MODE.  This change will be made available as part the releases that are going out this weekend.

You can view the docs using livedocs at http://docs.php.net/pdo
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 18 07:01:27 2024 UTC