diff options
author | ctrlaltca <ctrlaltca@gmail.com> | 2014-08-26 16:59:21 +0200 |
---|---|---|
committer | ctrlaltca <ctrlaltca@gmail.com> | 2014-08-26 16:59:21 +0200 |
commit | 74b31be9515eddfa63005d6760614badfaba9fea (patch) | |
tree | 47c952901dcb5eccd6dd8b7c6ee7e0b6bf176510 /framework/Data/Common | |
parent | 2b11341614ac4a15be697fa8acad07055154ac54 (diff) | |
parent | 0c5026b55cde5c104f10686afd8b441568175d38 (diff) |
Backports for Prado 3.2.4
Diffstat (limited to 'framework/Data/Common')
24 files changed, 165 insertions, 96 deletions
diff --git a/framework/Data/Common/Mssql/TMssqlCommandBuilder.php b/framework/Data/Common/Mssql/TMssqlCommandBuilder.php index efee34f9..ac718bcb 100644 --- a/framework/Data/Common/Mssql/TMssqlCommandBuilder.php +++ b/framework/Data/Common/Mssql/TMssqlCommandBuilder.php @@ -4,9 +4,8 @@ * * @author Wei Zhuo <weizhuo[at]gmail[dot]com> * @link http://www.pradosoft.com/ - * @copyright Copyright © 2005-2013 PradoSoft + * @copyright Copyright © 2005-2014 PradoSoft * @license http://www.pradosoft.com/license/ - * @version $Id: TDbCommandBuilder.php 1863 2007-04-12 12:43:49Z wei $ * @package System.Data.Common */ @@ -17,7 +16,6 @@ Prado::using('System.Data.Common.TDbCommandBuilder'); * for MSSQL servers. * * @author Wei Zhuo <weizho[at]gmail[dot]com> - * @version $Id: TDbCommandBuilder.php 1863 2007-04-12 12:43:49Z wei $ * @package System.Data.Common * @since 3.1 */ diff --git a/framework/Data/Common/Mssql/TMssqlMetaData.php b/framework/Data/Common/Mssql/TMssqlMetaData.php index 3ff7ac7f..21571428 100644 --- a/framework/Data/Common/Mssql/TMssqlMetaData.php +++ b/framework/Data/Common/Mssql/TMssqlMetaData.php @@ -4,9 +4,8 @@ * * @author Wei Zhuo <weizhuo[at]gmail[dot]com> * @link http://www.pradosoft.com/ - * @copyright Copyright © 2005-2013 PradoSoft + * @copyright Copyright © 2005-2014 PradoSoft * @license http://www.pradosoft.com/license/ - * @version $Id: TPgsqlMetaData.php 1866 2007-04-14 05:02:29Z wei $ * @package System.Data.Common.Mssql */ @@ -20,12 +19,11 @@ Prado::using('System.Data.Common.Mssql.TMssqlTableInfo'); * TMssqlMetaData loads MSSQL database table and column information. * * @author Wei Zhuo <weizho[at]gmail[dot]com> - * @version $Id: TPgsqlMetaData.php 1866 2007-04-14 05:02:29Z wei $ * @package System.Data.Common.Mssql * @since 3.1 */ class TMssqlMetaData extends TDbMetaData -{ +{ /** * @return string TDbTableInfo class name. */ @@ -260,5 +258,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; + } } diff --git a/framework/Data/Common/Mssql/TMssqlTableColumn.php b/framework/Data/Common/Mssql/TMssqlTableColumn.php index 7976c28a..e3bd431e 100644 --- a/framework/Data/Common/Mssql/TMssqlTableColumn.php +++ b/framework/Data/Common/Mssql/TMssqlTableColumn.php @@ -4,9 +4,8 @@ * * @author Wei Zhuo <weizhuo[at]gmail[dot]com> * @link http://www.pradosoft.com/ - * @copyright Copyright © 2005-2013 PradoSoft + * @copyright Copyright © 2005-2014 PradoSoft * @license http://www.pradosoft.com/license/ - * @version $Id: TMssqlTableColumn.php 1863 2007-04-12 12:43:49Z wei $ * @package System.Data.Common.Mssql */ @@ -19,7 +18,6 @@ Prado::using('System.Data.Common.TDbTableColumn'); * Describes the column metadata of the schema for a Mssql database table. * * @author Wei Zhuo <weizho[at]gmail[dot]com> - * @version $Id: TMssqlTableColumn.php 1863 2007-04-12 12:43:49Z wei $ * @package System.Data.Common.Mssql * @since 3.1 */ diff --git a/framework/Data/Common/Mssql/TMssqlTableInfo.php b/framework/Data/Common/Mssql/TMssqlTableInfo.php index 0db446b1..d003b336 100644 --- a/framework/Data/Common/Mssql/TMssqlTableInfo.php +++ b/framework/Data/Common/Mssql/TMssqlTableInfo.php @@ -4,9 +4,8 @@ * * @author Wei Zhuo <weizhuo[at]gmail[dot]com> * @link http://www.pradosoft.com/ - * @copyright Copyright © 2005-2013 PradoSoft + * @copyright Copyright © 2005-2014 PradoSoft * @license http://www.pradosoft.com/license/ - * @version $Id: TMssqlTableInfo.php 1861 2007-04-12 08:05:03Z wei $ * @package System.Data.Common.Mssql */ @@ -20,7 +19,6 @@ Prado::using('System.Data.Common.Mssql.TMssqlTableColumn'); * TMssqlTableInfo class provides additional table information for Mssql database. * * @author Wei Zhuo <weizho[at]gmail[dot]com> - * @version $Id: TMssqlTableInfo.php 1861 2007-04-12 08:05:03Z wei $ * @package System.Data.Common.Mssql * @since 3.1 */ diff --git a/framework/Data/Common/Mysql/TMysqlCommandBuilder.php b/framework/Data/Common/Mysql/TMysqlCommandBuilder.php index 8492c537..38e98b4f 100644 --- a/framework/Data/Common/Mysql/TMysqlCommandBuilder.php +++ b/framework/Data/Common/Mysql/TMysqlCommandBuilder.php @@ -4,9 +4,8 @@ * * @author Wei Zhuo <weizhuo[at]gmail[dot]com> * @link http://www.pradosoft.com/ - * @copyright Copyright © 2005-2013 PradoSoft + * @copyright Copyright © 2005-2014 PradoSoft * @license http://www.pradosoft.com/license/ - * @version $Id: TDbCommandBuilder.php 1863 2007-04-12 12:43:49Z wei $ * @package System.Data.Common */ @@ -16,7 +15,6 @@ Prado::using('System.Data.Common.TDbCommandBuilder'); * TMysqlCommandBuilder implements default TDbCommandBuilder * * @author Wei Zhuo <weizho[at]gmail[dot]com> - * @version $Id: TDbCommandBuilder.php 1863 2007-04-12 12:43:49Z wei $ * @package System.Data.Common * @since 3.1 */ diff --git a/framework/Data/Common/Mysql/TMysqlMetaData.php b/framework/Data/Common/Mysql/TMysqlMetaData.php index 9dc995fc..71c75501 100644 --- a/framework/Data/Common/Mysql/TMysqlMetaData.php +++ b/framework/Data/Common/Mysql/TMysqlMetaData.php @@ -4,9 +4,8 @@ * * @author Wei Zhuo <weizhuo[at]gmail[dot]com> * @link http://www.pradosoft.com/ - * @copyright Copyright © 2005-2013 PradoSoft + * @copyright Copyright © 2005-2014 PradoSoft * @license http://www.pradosoft.com/license/ - * @version $Id: TMysqlMetaData.php 3245 2013-01-07 20:23:32Z ctrlaltca $ * @package System.Data.Common.Mysql */ @@ -23,7 +22,6 @@ Prado::using('System.Data.Common.Mysql.TMysqlTableInfo'); * See http://netevil.org/node.php?nid=795&SC=1 * * @author Wei Zhuo <weizho[at]gmail[dot]com> - * @version $Id: TMysqlMetaData.php 3245 2013-01-07 20:23:32Z ctrlaltca $ * @package System.Data.Common.Mysql * @since 3.1 */ @@ -78,6 +76,9 @@ class TMysqlMetaData extends TDbMetaData { list($schemaName,$tableName) = $this->getSchemaTableName($table); $find = $schemaName===null ? "`{$tableName}`" : "`{$schemaName}`.`{$tableName}`"; + $colCase = $this->getDbConnection()->getColumnCase(); + if($colCase != TDbColumnCaseMode::Preserved) + $this->getDbConnection()->setColumnCase('Preserved'); $this->getDbConnection()->setActive(true); $sql = "SHOW FULL FIELDS FROM {$find}"; $command = $this->getDbConnection()->createCommand($sql); @@ -90,6 +91,8 @@ class TMysqlMetaData extends TDbMetaData } if($index===0) throw new TDbException('dbmetadata_invalid_table_view', $table); + if($colCase != TDbColumnCaseMode::Preserved) + $this->getDbConnection()->setColumnCase($colCase); return $tableInfo; } @@ -382,5 +385,21 @@ 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==='') + return $this->getDbConnection()->createCommand('SHOW TABLES')->queryColumn(); + $names=$this->getDbConnection()->createCommand('SHOW TABLES FROM '.$this->quoteTableName($schema))->queryColumn(); + foreach($names as &$name) + $name=$schema.'.'.$name; + return $names; + } } diff --git a/framework/Data/Common/Mysql/TMysqlTableColumn.php b/framework/Data/Common/Mysql/TMysqlTableColumn.php index 6f482537..dd62f0f6 100644 --- a/framework/Data/Common/Mysql/TMysqlTableColumn.php +++ b/framework/Data/Common/Mysql/TMysqlTableColumn.php @@ -4,9 +4,8 @@ * * @author Wei Zhuo <weizhuo[at]gmail[dot]com> * @link http://www.pradosoft.com/ - * @copyright Copyright © 2005-2013 PradoSoft + * @copyright Copyright © 2005-2014 PradoSoft * @license http://www.pradosoft.com/license/ - * @version $Id: TMysqlTableColumn.php 3245 2013-01-07 20:23:32Z ctrlaltca $ * @package System.Data.Common.Mysql */ @@ -19,7 +18,6 @@ Prado::using('System.Data.Common.TDbTableColumn'); * Describes the column metadata of the schema for a Mysql database table. * * @author Wei Zhuo <weizho[at]gmail[dot]com> - * @version $Id: TMysqlTableColumn.php 3245 2013-01-07 20:23:32Z ctrlaltca $ * @package System.Data.Common.Mysql * @since 3.1 */ diff --git a/framework/Data/Common/Mysql/TMysqlTableInfo.php b/framework/Data/Common/Mysql/TMysqlTableInfo.php index b190e961..17b32aa9 100644 --- a/framework/Data/Common/Mysql/TMysqlTableInfo.php +++ b/framework/Data/Common/Mysql/TMysqlTableInfo.php @@ -4,9 +4,8 @@ * * @author Wei Zhuo <weizhuo[at]gmail[dot]com> * @link http://www.pradosoft.com/ - * @copyright Copyright © 2005-2013 PradoSoft + * @copyright Copyright © 2005-2014 PradoSoft * @license http://www.pradosoft.com/license/ - * @version $Id: TMysqlTableInfo.php 3245 2013-01-07 20:23:32Z ctrlaltca $ * @package System.Data.Common.Mysql */ @@ -20,7 +19,6 @@ Prado::using('System.Data.Common.Mysql.TMysqlTableColumn'); * TMysqlTableInfo class provides additional table information for MySQL database. * * @author Wei Zhuo <weizho[at]gmail[dot]com> - * @version $Id: TMysqlTableInfo.php 3245 2013-01-07 20:23:32Z ctrlaltca $ * @package System.Data.Common.Mysql * @since 3.1 */ diff --git a/framework/Data/Common/Oracle/TOracleCommandBuilder.php b/framework/Data/Common/Oracle/TOracleCommandBuilder.php index 26490d54..56173c3a 100644 --- a/framework/Data/Common/Oracle/TOracleCommandBuilder.php +++ b/framework/Data/Common/Oracle/TOracleCommandBuilder.php @@ -5,9 +5,8 @@ * * @author Marcos Nobre <marconobre[at]gmail[dot]com> * @link http://www.pradosoft.com/ - * @copyright Copyright © 2005-2013 PradoSoft + * @copyright Copyright © 2005-2014 PradoSoft * @license http://www.pradosoft.com/license/ - * @version $Id: TOracleCommandBuilder.php 3245 2013-01-07 20:23:32Z ctrlaltca $ * @package System.Data.Common */ @@ -18,7 +17,6 @@ Prado :: using('System.Data.Common.TDbCommandBuilder'); * for Oracle database. * * @author Marcos Nobre <marconobre[at]gmail[dot]com> - * @version $Id: TOracleCommandBuilder.php 3245 2013-01-07 20:23:32Z ctrlaltca $ * @package System.Data.Common * @since 3.1 */ @@ -134,14 +132,14 @@ class TOracleCommandBuilder extends TDbCommandBuilder { " SELECT rownum as {$pradoNUMLIN} {$aliasedFields} FROM ". " ($sql) {$fieldsALIAS} WHERE rownum <= {$limit} ". ") WHERE {$pradoNUMLIN} >= {$offset} "; - + ************************* */ $offset=(int)$offset; $toReg = $offset + $limit ; $fullTableName = $this->getTableInfo()->getTableFullName(); - if (empty ($sORDERBY)) + if (empty ($sORDERBY)) $sORDERBY="ROWNUM"; - + $newSql = " SELECT $fields FROM " . "( " . " SELECT ROW_NUMBER() OVER ( ORDER BY {$sORDERBY} ) -1 as {$pradoNUMLIN} {$aliasedFields} " . diff --git a/framework/Data/Common/Oracle/TOracleMetaData.php b/framework/Data/Common/Oracle/TOracleMetaData.php index 793070ed..7b5bd195 100644 --- a/framework/Data/Common/Oracle/TOracleMetaData.php +++ b/framework/Data/Common/Oracle/TOracleMetaData.php @@ -4,9 +4,8 @@ * * @author Marcos Nobre <marconobre[at]gmail[dot]com> * @link http://www.pradosoft.com/ - * @copyright Copyright © 2005-2013 PradoSoft + * @copyright Copyright © 2005-2014 PradoSoft * @license http://www.pradosoft.com/license/ - * @version $Id: TOracleMetaData.php 3245 2013-01-07 20:23:32Z ctrlaltca $ * @package System.Data.Common.Oracle */ @@ -21,7 +20,6 @@ Prado::using('System.Data.Common.Oracle.TOracleTableColumn'); * TOracleMetaData loads Oracle database table and column information. * * @author Marcos Nobre <marconobre[at]gmail[dot]com> - * @version $Id: TOracleMetaData.php 3245 2013-01-07 20:23:32Z ctrlaltca $ * @package System.Data.Common.Oracle * @since 3.1 */ @@ -29,7 +27,7 @@ class TOracleMetaData extends TDbMetaData { private $_defaultSchema = 'system'; - + /** * @return string TDbTableInfo class name. */ @@ -336,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; + } +} diff --git a/framework/Data/Common/Oracle/TOracleTableColumn.php b/framework/Data/Common/Oracle/TOracleTableColumn.php index bbd7212c..bc89d8c5 100644 --- a/framework/Data/Common/Oracle/TOracleTableColumn.php +++ b/framework/Data/Common/Oracle/TOracleTableColumn.php @@ -4,9 +4,8 @@ * * @author Marcos Nobre <marconobre[at]gmail[dot]com> * @link http://www.pradosoft.com/ - * @copyright Copyright © 2005-2013 PradoSoft + * @copyright Copyright © 2005-2014 PradoSoft * @license http://www.pradosoft.com/license/ - * @version $Id: TOracleTableColumn.php 3245 2013-01-07 20:23:32Z ctrlaltca $ * @package System.Data.Common.Oracle */ @@ -19,14 +18,13 @@ Prado::using('System.Data.Common.TDbTableColumn'); * Describes the column metadata of the schema for a PostgreSQL database table. * * @author Marcos Nobre <marconobre[at]gmail[dot]com> - * @version $Id: TOracleTableColumn.php 3245 2013-01-07 20:23:32Z ctrlaltca $ * @package System.Data.Common.Oracle * @since 3.1 */ class TOracleTableColumn extends TDbTableColumn { private static $types=array( - 'numeric' => array( 'numeric' ) + 'numeric' => array( 'numeric' ) // 'integer' => array('bit', 'bit varying', 'real', 'serial', 'int', 'integer'), // 'boolean' => array('boolean'), // 'float' => array('bigint', 'bigserial', 'double precision', 'money', 'numeric') diff --git a/framework/Data/Common/Oracle/TOracleTableInfo.php b/framework/Data/Common/Oracle/TOracleTableInfo.php index 6aa31fd8..4a2e31fd 100644 --- a/framework/Data/Common/Oracle/TOracleTableInfo.php +++ b/framework/Data/Common/Oracle/TOracleTableInfo.php @@ -5,9 +5,8 @@ * * @author Marcos Nobre <marconobre[at]gmail[dot]com> * @link http://www.pradosoft.com/ - * @copyright Copyright © 2005-2013 PradoSoft + * @copyright Copyright © 2005-2014 PradoSoft * @license http://www.pradosoft.com/license/ - * @version $Id: TOracleTableInfo.php 3245 2013-01-07 20:23:32Z ctrlaltca $ * @package System.Data.Common */ @@ -15,7 +14,6 @@ * TDbTableInfo class describes the meta data of a database table. * * @author Wei Zhuo <weizho[at]gmail[dot]com> - * @version $Id: TOracleTableInfo.php 3245 2013-01-07 20:23:32Z ctrlaltca $ * @package System.Data.Common * @since 3.1 */ diff --git a/framework/Data/Common/Pgsql/TPgsqlCommandBuilder.php b/framework/Data/Common/Pgsql/TPgsqlCommandBuilder.php index eb975a1a..851dabb5 100644 --- a/framework/Data/Common/Pgsql/TPgsqlCommandBuilder.php +++ b/framework/Data/Common/Pgsql/TPgsqlCommandBuilder.php @@ -4,9 +4,8 @@ * * @author Wei Zhuo <weizhuo[at]gmail[dot]com> * @link http://www.pradosoft.com/ - * @copyright Copyright © 2005-2013 PradoSoft + * @copyright Copyright © 2005-2014 PradoSoft * @license http://www.pradosoft.com/license/ - * @version $Id: TDbCommandBuilder.php 1863 2007-04-12 12:43:49Z wei $ * @package System.Data.Common */ @@ -17,7 +16,6 @@ Prado::using('System.Data.Common.TDbCommandBuilder'); * for Pgsql database. * * @author Wei Zhuo <weizho[at]gmail[dot]com> - * @version $Id: TDbCommandBuilder.php 1863 2007-04-12 12:43:49Z wei $ * @package System.Data.Common * @since 3.1 */ diff --git a/framework/Data/Common/Pgsql/TPgsqlMetaData.php b/framework/Data/Common/Pgsql/TPgsqlMetaData.php index dd91dfdc..595f46e8 100644 --- a/framework/Data/Common/Pgsql/TPgsqlMetaData.php +++ b/framework/Data/Common/Pgsql/TPgsqlMetaData.php @@ -4,9 +4,8 @@ * * @author Wei Zhuo <weizhuo[at]gmail[dot]com> * @link http://www.pradosoft.com/ - * @copyright Copyright © 2005-2013 PradoSoft + * @copyright Copyright © 2005-2014 PradoSoft * @license http://www.pradosoft.com/license/ - * @version $Id: TPgsqlMetaData.php 3245 2013-01-07 20:23:32Z ctrlaltca $ * @package System.Data.Common.Pgsql */ @@ -20,7 +19,6 @@ Prado::using('System.Data.Common.Pgsql.TPgsqlTableInfo'); * TPgsqlMetaData loads PostgreSQL database table and column information. * * @author Wei Zhuo <weizho[at]gmail[dot]com> - * @version $Id: TPgsqlMetaData.php 3245 2013-01-07 20:23:32Z ctrlaltca $ * @package System.Data.Common.Pgsql * @since 3.1 */ @@ -418,5 +416,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='public') + { + if($schema==='') + $schema=self::DEFAULT_SCHEMA; + $sql=<<<EOD +SELECT table_name, table_schema FROM information_schema.tables +WHERE table_schema=:schema AND table_type='BASE TABLE' +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[]=$row['table_schema'].'.'.$row['table_name']; + } + return $names; + } } diff --git a/framework/Data/Common/Pgsql/TPgsqlTableColumn.php b/framework/Data/Common/Pgsql/TPgsqlTableColumn.php index da17a7d3..fd0fd23c 100644 --- a/framework/Data/Common/Pgsql/TPgsqlTableColumn.php +++ b/framework/Data/Common/Pgsql/TPgsqlTableColumn.php @@ -4,9 +4,8 @@ * * @author Wei Zhuo <weizhuo[at]gmail[dot]com> * @link http://www.pradosoft.com/ - * @copyright Copyright © 2005-2013 PradoSoft + * @copyright Copyright © 2005-2014 PradoSoft * @license http://www.pradosoft.com/license/ - * @version $Id: TPgsqlTableColumn.php 3245 2013-01-07 20:23:32Z ctrlaltca $ * @package System.Data.Common.Pgsql */ @@ -19,7 +18,6 @@ Prado::using('System.Data.Common.TDbTableColumn'); * Describes the column metadata of the schema for a PostgreSQL database table. * * @author Wei Zhuo <weizho[at]gmail[dot]com> - * @version $Id: TPgsqlTableColumn.php 3245 2013-01-07 20:23:32Z ctrlaltca $ * @package System.Data.Common.Pgsql * @since 3.1 */ diff --git a/framework/Data/Common/Pgsql/TPgsqlTableInfo.php b/framework/Data/Common/Pgsql/TPgsqlTableInfo.php index ef2b4575..43298ffa 100644 --- a/framework/Data/Common/Pgsql/TPgsqlTableInfo.php +++ b/framework/Data/Common/Pgsql/TPgsqlTableInfo.php @@ -4,9 +4,8 @@ * * @author Wei Zhuo <weizhuo[at]gmail[dot]com> * @link http://www.pradosoft.com/ - * @copyright Copyright © 2005-2013 PradoSoft + * @copyright Copyright © 2005-2014 PradoSoft * @license http://www.pradosoft.com/license/ - * @version $Id: TPgsqlTableInfo.php 3245 2013-01-07 20:23:32Z ctrlaltca $ * @package System.Data.Common.Pgsql */ @@ -20,7 +19,6 @@ Prado::using('System.Data.Common.Pgsql.TPgsqlTableColumn'); * TPgsqlTableInfo class provides additional table information for PostgreSQL database. * * @author Wei Zhuo <weizho[at]gmail[dot]com> - * @version $Id: TPgsqlTableInfo.php 3245 2013-01-07 20:23:32Z ctrlaltca $ * @package System.Data.Common.Pgsql * @since 3.1 */ diff --git a/framework/Data/Common/Sqlite/TSqliteCommandBuilder.php b/framework/Data/Common/Sqlite/TSqliteCommandBuilder.php index 396ec7c5..b442f7b4 100644 --- a/framework/Data/Common/Sqlite/TSqliteCommandBuilder.php +++ b/framework/Data/Common/Sqlite/TSqliteCommandBuilder.php @@ -4,9 +4,8 @@ * * @author Wei Zhuo <weizhuo[at]gmail[dot]com> * @link http://www.pradosoft.com/ - * @copyright Copyright © 2005-2013 PradoSoft + * @copyright Copyright © 2005-2014 PradoSoft * @license http://www.pradosoft.com/license/ - * @version $Id: TDbCommandBuilder.php 1863 2007-04-12 12:43:49Z wei $ * @package System.Data.Common */ @@ -17,7 +16,6 @@ Prado::using('System.Data.Common.TDbCommandBuilder'); * for Sqlite database. * * @author Wei Zhuo <weizho[at]gmail[dot]com> - * @version $Id: TDbCommandBuilder.php 1863 2007-04-12 12:43:49Z wei $ * @package System.Data.Common * @since 3.1 */ diff --git a/framework/Data/Common/Sqlite/TSqliteMetaData.php b/framework/Data/Common/Sqlite/TSqliteMetaData.php index 3d789500..9bc345f3 100644 --- a/framework/Data/Common/Sqlite/TSqliteMetaData.php +++ b/framework/Data/Common/Sqlite/TSqliteMetaData.php @@ -4,9 +4,8 @@ * * @author Wei Zhuo <weizhuo[at]gmail[dot]com> * @link http://www.pradosoft.com/ - * @copyright Copyright © 2005-2013 PradoSoft + * @copyright Copyright © 2005-2014 PradoSoft * @license http://www.pradosoft.com/license/ - * @version $Id: TSqliteMetaData.php 1861 2007-04-12 08:05:03Z wei $ * @package System.Data.Common.Sqlite */ @@ -20,7 +19,6 @@ Prado::using('System.Data.Common.Sqlite.TSqliteTableInfo'); * TSqliteMetaData loads SQLite database table and column information. * * @author Wei Zhuo <weizho[at]gmail[dot]com> - * @version $Id: TSqliteMetaData.php 1861 2007-04-12 08:05:03Z wei $ * @package System.Data.Commom.Sqlite * @since 3.1 */ @@ -190,21 +188,15 @@ class TSqliteMetaData extends TDbMetaData } return false; } + + /** + * Returns all table names in the database. + * @param string $schema the schema of the tables. This is not used for sqlite database. + * @return array all table names in the database. + */ + public function findTableNames($schema='') + { + $sql="SELECT DISTINCT tbl_name FROM sqlite_master WHERE tbl_name<>'sqlite_sequence'"; + return $this->getDbConnection()->createCommand($sql)->queryColumn(); + } } - -/** - -CREATE TABLE foo -( - id INTEGER NOT NULL PRIMARY KEY, - id2 CHAR(2) -); - -CREATE TABLE bar -( - id INTEGER NOT NULL PRIMARY KEY, - foo_id INTEGER - CONSTRAINT fk_foo_id REFERENCES foo(id) ON DELETE CASCADE -); -*/ - diff --git a/framework/Data/Common/Sqlite/TSqliteTableColumn.php b/framework/Data/Common/Sqlite/TSqliteTableColumn.php index d8fd1966..f54b6f59 100644 --- a/framework/Data/Common/Sqlite/TSqliteTableColumn.php +++ b/framework/Data/Common/Sqlite/TSqliteTableColumn.php @@ -4,9 +4,8 @@ * * @author Wei Zhuo <weizhuo[at]gmail[dot]com> * @link http://www.pradosoft.com/ - * @copyright Copyright © 2005-2013 PradoSoft + * @copyright Copyright © 2005-2014 PradoSoft * @license http://www.pradosoft.com/license/ - * @version $Id: TSqliteTableColumn.php 1861 2007-04-12 08:05:03Z wei $ * @package System.Data.Common.Sqlite */ @@ -19,7 +18,6 @@ Prado::using('System.Data.Common.TDbTableColumn'); * Describes the column metadata of the schema for a PostgreSQL database table. * * @author Wei Zhuo <weizho[at]gmail[dot]com> - * @version $Id: TSqliteTableColumn.php 1861 2007-04-12 08:05:03Z wei $ * @package System.Data.Common.Sqlite * @since 3.1 */ diff --git a/framework/Data/Common/Sqlite/TSqliteTableInfo.php b/framework/Data/Common/Sqlite/TSqliteTableInfo.php index 52fb3530..e15f050a 100644 --- a/framework/Data/Common/Sqlite/TSqliteTableInfo.php +++ b/framework/Data/Common/Sqlite/TSqliteTableInfo.php @@ -4,9 +4,8 @@ * * @author Wei Zhuo <weizhuo[at]gmail[dot]com> * @link http://www.pradosoft.com/ - * @copyright Copyright © 2005-2013 PradoSoft + * @copyright Copyright © 2005-2014 PradoSoft * @license http://www.pradosoft.com/license/ - * @version $Id: TSqliteTableInfo.php 1861 2007-04-12 08:05:03Z wei $ * @package System.Data.Common.Sqlite */ @@ -20,7 +19,6 @@ Prado::using('System.Data.Common.Sqlite.TSqliteTableColumn'); * TSqliteTableInfo class provides additional table information for PostgreSQL database. * * @author Wei Zhuo <weizho[at]gmail[dot]com> - * @version $Id: TSqliteTableInfo.php 1861 2007-04-12 08:05:03Z wei $ * @package System.Data.Common.Sqlite * @since 3.1 */ diff --git a/framework/Data/Common/TDbCommandBuilder.php b/framework/Data/Common/TDbCommandBuilder.php index fdaa3bfe..7a7b75d4 100644 --- a/framework/Data/Common/TDbCommandBuilder.php +++ b/framework/Data/Common/TDbCommandBuilder.php @@ -4,9 +4,8 @@ * * @author Wei Zhuo <weizhuo[at]gmail[dot]com> * @link http://www.pradosoft.com/ - * @copyright Copyright © 2005-2013 PradoSoft + * @copyright Copyright © 2005-2014 PradoSoft * @license http://www.pradosoft.com/license/ - * @version $Id: TDbCommandBuilder.php 3245 2013-01-07 20:23:32Z ctrlaltca $ * @package System.Data.Common */ @@ -15,7 +14,6 @@ * giving by {@link setTableInfo TableInfo} the property. * * @author Wei Zhuo <weizho[at]gmail[dot]com> - * @version $Id: TDbCommandBuilder.php 3245 2013-01-07 20:23:32Z ctrlaltca $ * @package System.Data.Common * @since 3.1 */ diff --git a/framework/Data/Common/TDbMetaData.php b/framework/Data/Common/TDbMetaData.php index 2ad5c592..5b4568cb 100644 --- a/framework/Data/Common/TDbMetaData.php +++ b/framework/Data/Common/TDbMetaData.php @@ -4,9 +4,8 @@ * * @author Wei Zhuo <weizhuo[at]gmail[dot]com> * @link http://www.pradosoft.com/ - * @copyright Copyright © 2005-2013 PradoSoft + * @copyright Copyright © 2005-2014 PradoSoft * @license http://www.pradosoft.com/license/ - * @version $Id: TDbMetaData.php 3284 2013-04-11 07:14:59Z ctrlaltca $ * @package System.Data.Common */ @@ -17,7 +16,6 @@ * Use the {@link getTableInfo} method to retrieve a table information. * * @author Wei Zhuo <weizho[at]gmail[dot]com> - * @version $Id: TDbMetaData.php 3284 2013-04-11 07:14:59Z ctrlaltca $ * @package System.Data.Common * @since 3.1 */ @@ -180,5 +178,15 @@ abstract class TDbMetaData extends TComponent return $lft . str_replace(self::$delimiterIdentifier, '', $name) . $rgt; } + + /** + * Returns all table names in the database. + * This method should be overridden by child classes in order to support this feature + * because the default implementation simply throws an exception. + * @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. + */ + abstract public function findTableNames($schema=''); } diff --git a/framework/Data/Common/TDbTableColumn.php b/framework/Data/Common/TDbTableColumn.php index 27cfb7c5..fe96e12a 100644 --- a/framework/Data/Common/TDbTableColumn.php +++ b/framework/Data/Common/TDbTableColumn.php @@ -4,9 +4,8 @@ * * @author Wei Zhuo <weizhuo[at]gmail[dot]com> * @link http://www.pradosoft.com/ - * @copyright Copyright © 2005-2013 PradoSoft + * @copyright Copyright © 2005-2014 PradoSoft * @license http://www.pradosoft.com/license/ - * @version $Id: TDbTableColumn.php 3245 2013-01-07 20:23:32Z ctrlaltca $ * @package System.Data.Common */ @@ -14,7 +13,6 @@ * TDbTableColumn class describes the column meta data of the schema for a database table. * * @author Wei Zhuo <weizho[at]gmail[dot]com> - * @version $Id: TDbTableColumn.php 3245 2013-01-07 20:23:32Z ctrlaltca $ * @package System.Data.Common * @since 3.1 */ diff --git a/framework/Data/Common/TDbTableInfo.php b/framework/Data/Common/TDbTableInfo.php index fbfcf46d..5060845b 100644 --- a/framework/Data/Common/TDbTableInfo.php +++ b/framework/Data/Common/TDbTableInfo.php @@ -4,9 +4,8 @@ * * @author Wei Zhuo <weizhuo[at]gmail[dot]com> * @link http://www.pradosoft.com/ - * @copyright Copyright © 2005-2013 PradoSoft + * @copyright Copyright © 2005-2014 PradoSoft * @license http://www.pradosoft.com/license/ - * @version $Id: TDbTableInfo.php 3245 2013-01-07 20:23:32Z ctrlaltca $ * @package System.Data.Common */ @@ -14,7 +13,6 @@ * TDbTableInfo class describes the meta data of a database table. * * @author Wei Zhuo <weizho[at]gmail[dot]com> - * @version $Id: TDbTableInfo.php 3245 2013-01-07 20:23:32Z ctrlaltca $ * @package System.Data.Common * @since 3.1 */ |