summaryrefslogtreecommitdiff
path: root/framework/Data/Common/Mssql
diff options
context:
space:
mode:
authorDaniel <darthdaniel85@gmail.com>2013-12-09 02:04:04 -0500
committerDaniel <darthdaniel85@gmail.com>2013-12-09 02:04:04 -0500
commit4312f846098706c19576a4438704a5f22eb2d32d (patch)
tree012d2c682821d23c56a3804aa8eeddbc5584c694 /framework/Data/Common/Mssql
parente04fb5c765252593fb88fb56eaefbdc88bbeb7d1 (diff)
Support for all PRADO DB drivers!
Diffstat (limited to 'framework/Data/Common/Mssql')
-rw-r--r--framework/Data/Common/Mssql/TMssqlMetaData.php30
1 files changed, 29 insertions, 1 deletions
diff --git a/framework/Data/Common/Mssql/TMssqlMetaData.php b/framework/Data/Common/Mssql/TMssqlMetaData.php
index 3ff7ac7f..8ee455d5 100644
--- a/framework/Data/Common/Mssql/TMssqlMetaData.php
+++ b/framework/Data/Common/Mssql/TMssqlMetaData.php
@@ -25,7 +25,7 @@ Prado::using('System.Data.Common.Mssql.TMssqlTableInfo');
* @since 3.1
*/
class TMssqlMetaData extends TDbMetaData
-{
+{
/**
* @return string TDbTableInfo class name.
*/
@@ -260,5 +260,33 @@ 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='dbo')
+ {
+ $condition="TABLE_TYPE='BASE TABLE'";
+ $sql=<<<EOD
+SELECT TABLE_NAME, TABLE_SCHEMA FROM [INFORMATION_SCHEMA].[TABLES]
+WHERE TABLE_SCHEMA=:schema AND $condition
+EOD;
+ $command=$this->getDbConnection()->createCommand($sql);
+ $command->bindParam(":schema", $schema);
+ $rows=$command->queryAll();
+ $names=array();
+ foreach ($rows as $row)
+ {
+ if ($schema == self::DEFAULT_SCHEMA)
+ $names[]=$row['TABLE_NAME'];
+ else
+ $names[]=$schema.'.'.$row['TABLE_SCHEMA'].'.'.$row['TABLE_NAME'];
+ }
+
+ return $names;
+ }
}