summaryrefslogtreecommitdiff
path: root/framework/Data/Common/Pgsql/TPgsqlMetaData.php
diff options
context:
space:
mode:
authorGODZilla0480@gmail.com <>2011-08-28 06:24:03 +0000
committerGODZilla0480@gmail.com <>2011-08-28 06:24:03 +0000
commitfb494d1e299e256721cba77105a01b7480c48c08 (patch)
tree60a126bd254916501f45f8034108a77c580bd0bc /framework/Data/Common/Pgsql/TPgsqlMetaData.php
parent5ad92b6fe39f04aad8d94f32d23c7e665725fe8c (diff)
Add methods quoteTableName, quoteColumnName, quoteColumnAlias to TDbMetaData & TDbConnection and add TDbConnection:getDbMetaData [TODO: customize TOracleMetaData]
Diffstat (limited to 'framework/Data/Common/Pgsql/TPgsqlMetaData.php')
-rw-r--r--framework/Data/Common/Pgsql/TPgsqlMetaData.php38
1 files changed, 34 insertions, 4 deletions
diff --git a/framework/Data/Common/Pgsql/TPgsqlMetaData.php b/framework/Data/Common/Pgsql/TPgsqlMetaData.php
index 5ac57239..e57f1b37 100644
--- a/framework/Data/Common/Pgsql/TPgsqlMetaData.php
+++ b/framework/Data/Common/Pgsql/TPgsqlMetaData.php
@@ -4,7 +4,7 @@
*
* @author Wei Zhuo <weizhuo[at]gmail[dot]com>
* @link http://www.pradosoft.com/
- * @copyright Copyright &copy; 2005-2011 PradoSoft
+ * @copyright Copyright &copy; 2005-2011 PradoSoft
* @license http://www.pradosoft.com/license/
* @version $Id$
* @package System.Data.Common.Pgsql
@@ -37,6 +37,36 @@ class TPgsqlMetaData extends TDbMetaData
}
/**
+ * Quotes a table name for use in a query.
+ * @param string $name table name
+ * @return string the properly quoted table name
+ */
+ public function quoteTableName($name)
+ {
+ return parent::quoteTableName($name, '"', '"');
+ }
+
+ /**
+ * Quotes a column name for use in a query.
+ * @param string $name column name
+ * @return string the properly quoted column name
+ */
+ public function quoteColumnName($name)
+ {
+ return parent::quoteColumnName($name, '"', '"');
+ }
+
+ /**
+ * Quotes a column alias for use in a query.
+ * @param string $name column alias
+ * @return string the properly quoted column alias
+ */
+ public function quoteColumnAlias($name)
+ {
+ return parent::quoteColumnAlias($name, '"', '"');
+ }
+
+ /**
* @param string default schema.
*/
public function setDefaultSchema($schema)
@@ -333,13 +363,13 @@ EOD;
$index = join(', ', explode(' ', $columnIndex));
$sql =
<<<EOD
- SELECT attnum, attname FROM pg_catalog.pg_attribute WHERE
+ SELECT attnum, attname FROM pg_catalog.pg_attribute WHERE
attrelid=(
SELECT oid FROM pg_catalog.pg_class WHERE relname=:table AND relnamespace=(
SELECT oid FROM pg_catalog.pg_namespace WHERE nspname=:schema
)
)
- AND attnum IN ({$index})
+ AND attnum IN ({$index})
EOD;
$command = $this->getDbConnection()->createCommand($sql);
$command->bindValue(':table', $tableName);
@@ -348,7 +378,7 @@ EOD;
$primary = array();
foreach($command->query() as $row)
{
- $primary[] = $row['attname'];
+ $primary[] = $row['attname'];
}
return $primary;