Home » Database » MDB » Bug #968
[MDB1] Feature request: oci8 listTables()
Details
| Submitted | 2004-03-08 04:43 UTC |
|---|---|
| From | thierrybo at freesurf dot fr |
| Assigned | lsmith |
| Status | Closed |
| Package | MDB |
| PHP Version | 4.3.2 |
| OS | win32XP |
| Roadmaps | (Not assigned) |
Comments
[2004-03-08 04:43 UTC] thierrybo at freesurf dot fr
Description:
------------
I need the listTables() method for oci8. Here is the code.
I use the USER_TABLES view instead of ALL_TABLES. This restricts the table list to those tables owned by the calling user rather than those accessible to the calling user. This is necessary because if we need to know if a table exist in one schema (typically the user schema), ALL_TABLES may returns tables with the same name in more than one schema, or return the name of the table we are looking for, but from another schema.
Also, perhaps you may lower case of field name if 'portability' is set?
Thierry Bothorel
348,363d347
< // {{{ listTables()
<
< /**
< * list all tables in the current database
< *
< * @param object $db database object that is extended by this class
< * @return mixed data array on success, a MDB error on failure
< * @access public
< **/
< function listTables(&$db)
< {
< $sql = "SELECT table_name FROM sys.user_tables";
< return($db->queryCol($sql));
< }
<
< // }}}
[2004-03-09 00:07 UTC] thierrybo at freesurf dot fr
After tweaking with this, I changes my previous code to lower case tables names. The point is, do I need to lwer case them only if 'portability' is set, or every time? :
function listTables(&$db)
{
$sql = "SELECT table_name FROM sys.user_tables";
$table_names = $db->queryCol($sql);
if ($db->options['optimize'] == 'portability') {
$table_names = array_flip($table_names);
$table_names = array_change_key_case($table_names, CASE_LOWER);
$table_names = array_flip($table_names);
}
return($table_names);
}
[2004-03-10 17:32 UTC] thierrybo at freesurf dot fr
I would like to, but for the moment I have really no idea how this beast works!