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/Mysql/TMysqlMetaData.php | |
| parent | 2b11341614ac4a15be697fa8acad07055154ac54 (diff) | |
| parent | 0c5026b55cde5c104f10686afd8b441568175d38 (diff) | |
Backports for Prado 3.2.4
Diffstat (limited to 'framework/Data/Common/Mysql/TMysqlMetaData.php')
| -rw-r--r-- | framework/Data/Common/Mysql/TMysqlMetaData.php | 25 | 
1 files changed, 22 insertions, 3 deletions
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; +	}  }  | 
