RE : [PEAR] MDB Error with OCI8 listTables
| From: | Vincent DUPONT | Date: | Fri, 01 Oct 2004 19:54:12 +0000 |
| Subject: | RE : [PEAR] MDB Error with OCI8 listTables | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-14720@lists.php.net to get a copy of this message | ||
Thank you Lukas for your help
I found the BUG
MDB 1.3.0, Manager_oci8 line 350
function listTables(&$db)
{
$query = 'SELECT table_name FROM sys.user_tables';
return($db->queryCol($sql));
}
The query is stored in variable named "$query"
but we try to execute the $sql =>error $sql is undefined !!!
So rename $sql to $query
I re-extracted the MDB 1.3 archive and found the same. So this is not a typo I made in the source
code...
I tested this modification and it works well.
Lukas, could you please follow this info so as to update the cvs and next releases? Thank you,
Vincent
-------- Message d'origine--------
De: Vincent DUPONT
Date: ven. 1/10/2004 14:55
À: pear-general@lists.php.net
Cc:
Objet: [PEAR] MDB Error with OCI8 listTables
HI,
The changelog of MDB indicates since 1.3.0 :
MDB_Manager_oci8:
- added listTables() and listTableFields()
So I updated my PEAR repository to get MDB 1.3.0
However, I tried the simple script below and it works with MySQL but not with OCI8 (oracle9i).
The query used in Manager_oci8 (SELECT table_name FROM sys.user_tables) works, so I don't
understand where does the MDB error come from.
Any help is welcome.
Vincent
<?php
require_once('MDB.php');
$dsn = "mysql://user:password@localhost/aw_system"; //This works with MySql
$dsn = "oci8://user:password@ORCL92"; //This generates an error
$conn = MDB::connect($dsn);
if(MDB::isError($conn)){
die("unable to connect to the DB");
}
$tables = $conn->listTables();
if(MDB::isError($tables)){
$output = "Class :".get_class($tables)."\n";
$output .= "Message :".$tables->getMessage()."\n";
$output .= "Code : ".$tables->getCode()."\n";
$output .= "Type : ".$tables->getType()."\n";
$output .= "Mode : ".$tables->getMode()."\n";
print_r($tables->getBacktrace());
die("Error While getting the tables.".$output);
}
echo "tables for <b>$dsn</b><p>";
for ($i=0; $i<sizeof($tables); $i++){
echo "<b><u>".$tables[$i]."</u></b><br>";
$fields = $conn->listTableFields($tables[$i]);
if(MDB::isError($fields)){
die("Error While getting the fields for table ".$tables[$i].".
".$fields->getMessage());
}
for($j=0; $j<sizeof($fields);$j++){
echo " ".$fields[$j]."<br>";
}
}
echo "<p>End...<p>";
$conn->disconnect();
?>