From 3392e51b4edf84682b66ce9e32d00c1adb3205bb Mon Sep 17 00:00:00 2001 From: wei <> Date: Tue, 8 May 2007 07:49:50 +0000 Subject: Fixed sqlmap query with limit and offsets. --- framework/Data/Common/Mssql/TMssqlMetaData.php | 11 ++++++++++- framework/Data/Common/Mysql/TMysqlMetaData.php | 11 ++++++++++- framework/Data/Common/Pgsql/TPgsqlMetaData.php | 11 ++++++++++- framework/Data/Common/Sqlite/TSqliteMetaData.php | 11 ++++++++++- framework/Data/Common/TDbMetaData.php | 23 ++++++++++++++++++----- framework/Data/Common/TDbTableInfo.php | 2 +- 6 files changed, 59 insertions(+), 10 deletions(-) (limited to 'framework/Data/Common') diff --git a/framework/Data/Common/Mssql/TMssqlMetaData.php b/framework/Data/Common/Mssql/TMssqlMetaData.php index 72d297f7..37ce124f 100644 --- a/framework/Data/Common/Mssql/TMssqlMetaData.php +++ b/framework/Data/Common/Mssql/TMssqlMetaData.php @@ -26,6 +26,14 @@ Prado::using('System.Data.Common.Mssql.TMssqlTableInfo'); */ class TMssqlMetaData extends TDbMetaData { + /** + * @return string TDbTableInfo class name. + */ + protected function getTableInfoClass() + { + return 'TMssqlTableInfo'; + } + /** * Get the column definitions for given table. * @param string table name. @@ -130,7 +138,8 @@ EOD; if($col['TABLE_TYPE']==='VIEW') $info['IsView'] = true; list($primary, $foreign) = $this->getConstraintKeys($col); - return new TMssqlTableInfo($info,$primary,$foreign); + $class = $this->getTableInfoClass(); + return new $class($info,$primary,$foreign); } /** diff --git a/framework/Data/Common/Mysql/TMysqlMetaData.php b/framework/Data/Common/Mysql/TMysqlMetaData.php index 89e9e3ca..3b9a12f7 100644 --- a/framework/Data/Common/Mysql/TMysqlMetaData.php +++ b/framework/Data/Common/Mysql/TMysqlMetaData.php @@ -31,6 +31,14 @@ class TMysqlMetaData extends TDbMetaData { private $_serverVersion=0; + /** + * @return string TDbTableInfo class name. + */ + protected function getTableInfoClass() + { + return 'TMysqlTableInfo'; + } + /** * Get the column definitions for given table. * @param string table name. @@ -185,7 +193,8 @@ class TMysqlMetaData extends TDbMetaData if($this->getIsView($schemaName,$tableName)) $info['IsView'] = true; list($primary, $foreign) = $this->getConstraintKeys($schemaName, $tableName); - return new TMysqlTableInfo($info,$primary,$foreign); + $class = $this->getTableInfoClass(); + return new $class($info,$primary,$foreign); } /** diff --git a/framework/Data/Common/Pgsql/TPgsqlMetaData.php b/framework/Data/Common/Pgsql/TPgsqlMetaData.php index c68bbaa0..0b647445 100644 --- a/framework/Data/Common/Pgsql/TPgsqlMetaData.php +++ b/framework/Data/Common/Pgsql/TPgsqlMetaData.php @@ -28,6 +28,14 @@ class TPgsqlMetaData extends TDbMetaData { private $_defaultSchema = 'public'; + /** + * @return string TDbTableInfo class name. + */ + protected function getTableInfoClass() + { + return 'TPgsqlTableInfo'; + } + /** * @param string default schema. */ @@ -126,7 +134,8 @@ EOD; if($this->getIsView($schemaName,$tableName)) $info['IsView'] = true; list($primary, $foreign) = $this->getConstraintKeys($schemaName, $tableName); - return new TPgsqlTableInfo($info,$primary,$foreign); + $class = $this->getTableInfoClass(); + return new $class($info,$primary,$foreign); } /** diff --git a/framework/Data/Common/Sqlite/TSqliteMetaData.php b/framework/Data/Common/Sqlite/TSqliteMetaData.php index 5e1c5f77..aa2ed724 100644 --- a/framework/Data/Common/Sqlite/TSqliteMetaData.php +++ b/framework/Data/Common/Sqlite/TSqliteMetaData.php @@ -26,6 +26,14 @@ Prado::using('System.Data.Common.Sqlite.TSqliteTableInfo'); */ class TSqliteMetaData extends TDbMetaData { + /** + * @return string TDbTableInfo class name. + */ + protected function getTableInfoClass() + { + return 'TSqliteTableInfo'; + } + /** * Get the column definitions for given table. * @param string table name. @@ -55,7 +63,8 @@ class TSqliteMetaData extends TDbMetaData $info['IsView'] = true; if(count($columns)===0) throw new TDbException('dbmetadata_invalid_table_view', $tableName); - $tableInfo = new TSqliteTableInfo($info,$primary,$foreign); + $class = $this->getTableInfoClass(); + $tableInfo = new $class($info,$primary,$foreign); $tableInfo->getColumns()->copyFrom($columns); return $tableInfo; } diff --git a/framework/Data/Common/TDbMetaData.php b/framework/Data/Common/TDbMetaData.php index d0963f44..e7c53618 100644 --- a/framework/Data/Common/TDbMetaData.php +++ b/framework/Data/Common/TDbMetaData.php @@ -80,11 +80,16 @@ abstract class TDbMetaData extends TComponent * @param string table or view name * @return TDbTableInfo table information. */ - public function getTableInfo($tableName) + public function getTableInfo($tableName=null) { - if(!isset($this->_tableInfoCache[$tableName])) - $this->_tableInfoCache[$tableName] = $this->createTableInfo($tableName); - return $this->_tableInfoCache[$tableName]; + $key = $tableName===null?$this->getDbConnection()->getConnectionString():$tableName; + if(!isset($this->_tableInfoCache[$key])) + { + $class = $this->getTableInfoClass(); + $tableInfo = $tableName===null ? new $class : $this->createTableInfo($tableName); + $this->_tableInfoCache[$key] = $tableInfo; + } + return $this->_tableInfoCache[$key]; } /** @@ -92,7 +97,7 @@ abstract class TDbMetaData extends TComponent * @param string table name. * @return TDbCommandBuilder command builder instance for the given table. */ - public function createCommandBuilder($tableName) + public function createCommandBuilder($tableName=null) { return $this->getTableInfo($tableName)->createCommandBuilder($this->getDbConnection()); } @@ -102,6 +107,14 @@ abstract class TDbMetaData extends TComponent * @return TDbTableInfo driver dependent create builder. */ abstract protected function createTableInfo($tableName); + + /** + * @return string TDbTableInfo class name. + */ + protected function getTableInfoClass() + { + return 'TDbTableInfo'; + } } ?> \ No newline at end of file diff --git a/framework/Data/Common/TDbTableInfo.php b/framework/Data/Common/TDbTableInfo.php index 9689630f..ee5d2d00 100644 --- a/framework/Data/Common/TDbTableInfo.php +++ b/framework/Data/Common/TDbTableInfo.php @@ -33,7 +33,7 @@ class TDbTableInfo extends TComponent * Sets the database table meta data information. * @param array table column information. */ - public function __construct($tableInfo,$primary=array(),$foreign=array()) + public function __construct($tableInfo=array(),$primary=array(),$foreign=array()) { $this->_info=$tableInfo; $this->_primaryKeys=$primary; -- cgit v1.2.3