diff options
Diffstat (limited to 'framework/Data/Common/Oracle')
4 files changed, 46 insertions, 18 deletions
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 */ |