summaryrefslogtreecommitdiff
path: root/framework/Data/Common/Oracle
diff options
context:
space:
mode:
authorDaniel <darthdaniel85@gmail.com>2013-12-09 02:04:04 -0500
committerFabio Bas <ctrlaltca@gmail.com>2014-08-26 13:14:33 +0200
commit93792e60746f8d34fa675ba834ca36552f6016df (patch)
tree01052bbff4b2aafb8483e95bb8d8974dd7d1c164 /framework/Data/Common/Oracle
parent6d4278bcaf8951e748ee08edd8db412588244217 (diff)
Support for all PRADO DB drivers!
Diffstat (limited to 'framework/Data/Common/Oracle')
-rw-r--r--framework/Data/Common/Oracle/TOracleMetaData.php38
1 files changed, 37 insertions, 1 deletions
diff --git a/framework/Data/Common/Oracle/TOracleMetaData.php b/framework/Data/Common/Oracle/TOracleMetaData.php
index 6f495aeb..7b5bd195 100644
--- a/framework/Data/Common/Oracle/TOracleMetaData.php
+++ b/framework/Data/Common/Oracle/TOracleMetaData.php
@@ -334,5 +334,41 @@ EOD;
}
return false;
}
-}
+
+ /**
+ * Returns all table names in the database.
+ * @param string $schema the schema of the tables. Defaults to empty string, meaning the current or default schema.
+ * If not empty, the returned table names will be prefixed with the schema name.
+ * @return array all table names in the database.
+ */
+ public function findTableNames($schema='')
+ {
+ if($schema==='')
+ {
+ $sql=<<<EOD
+SELECT table_name, '{$schema}' as table_schema FROM user_tables
+EOD;
+ $command=$this->getDbConnection()->createCommand($sql);
+ }
+ else
+ {
+ $sql=<<<EOD
+SELECT object_name as table_name, owner as table_schema FROM all_objects
+WHERE object_type = 'TABLE' AND owner=:schema
+EOD;
+ $command=$this->getDbConnection()->createCommand($sql);
+ $command->bindParam(':schema',$schema);
+ }
+ $rows=$command->queryAll();
+ $names=array();
+ foreach($rows as $row)
+ {
+ if($schema===$this->getDefaultSchema() || $schema==='')
+ $names[]=$row['TABLE_NAME'];
+ else
+ $names[]=$row['TABLE_SCHEMA'].'.'.$row['TABLE_NAME'];
+ }
+ return $names;
+ }
+}