From dfd15a6068bbd3251198c47b6a55ee833a4b000c Mon Sep 17 00:00:00 2001 From: romanb Date: Tue, 30 Oct 2007 13:30:50 +0000 Subject: [PATCH] Introduced ATTR_TBLNAME_FORMAT. Closes #257 --- lib/Doctrine.php | 1 + lib/Doctrine/Formatter.php | 12 ++++++++++++ lib/Doctrine/Manager.php | 1 + lib/Doctrine/Record/Abstract.php | 2 +- lib/Doctrine/Table.php | 2 +- 5 files changed, 16 insertions(+), 2 deletions(-) diff --git a/lib/Doctrine.php b/lib/Doctrine.php index 1bf1b3c7b..813be93d5 100644 --- a/lib/Doctrine.php +++ b/lib/Doctrine.php @@ -160,6 +160,7 @@ final class Doctrine const ATTR_CMPNAME_FORMAT = 118; const ATTR_DBNAME_FORMAT = 117; const ATTR_TBLCLASS_FORMAT = 119; + const ATTR_TBLNAME_FORMAT = 120; const ATTR_EXPORT = 140; const ATTR_DECIMAL_PLACES = 141; diff --git a/lib/Doctrine/Formatter.php b/lib/Doctrine/Formatter.php index 311f23098..b6aa80959 100644 --- a/lib/Doctrine/Formatter.php +++ b/lib/Doctrine/Formatter.php @@ -226,4 +226,16 @@ class Doctrine_Formatter extends Doctrine_Connection_Module return sprintf($this->conn->getAttribute(Doctrine::ATTR_IDXNAME_FORMAT), preg_replace('/[^a-z0-9_\$]/i', '_', $idx)); } + + /** + * adds table name formatting to a table name + * + * @param string name of the table + * @return string formatted table name + */ + public function getTableName($table) + { + return sprintf($this->conn->getAttribute(Doctrine::ATTR_TBLNAME_FORMAT), + preg_replace('/[^a-z0-9_\$]/i', '_', $table)); + } } \ No newline at end of file diff --git a/lib/Doctrine/Manager.php b/lib/Doctrine/Manager.php index 674b96c1c..0808c6681 100644 --- a/lib/Doctrine/Manager.php +++ b/lib/Doctrine/Manager.php @@ -99,6 +99,7 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera Doctrine::ATTR_QUERY_LIMIT => Doctrine::LIMIT_RECORDS, Doctrine::ATTR_IDXNAME_FORMAT => "%s_idx", Doctrine::ATTR_SEQNAME_FORMAT => "%s_seq", + Doctrine::ATTR_TBLNAME_FORMAT => "%s", Doctrine::ATTR_QUOTE_IDENTIFIER => false, Doctrine::ATTR_SEQCOL_NAME => 'id', Doctrine::ATTR_PORTABILITY => Doctrine::PORTABILITY_ALL, diff --git a/lib/Doctrine/Record/Abstract.php b/lib/Doctrine/Record/Abstract.php index 4ead239b8..b845ee446 100644 --- a/lib/Doctrine/Record/Abstract.php +++ b/lib/Doctrine/Record/Abstract.php @@ -97,7 +97,7 @@ abstract class Doctrine_Record_Abstract extends Doctrine_Access } public function setTableName($tableName) { - $this->_table->setOption('tableName', $tableName); + $this->_table->setTableName($tableName); } public function setInheritanceMap($map) { diff --git a/lib/Doctrine/Table.php b/lib/Doctrine/Table.php index 2749f8e0a..f507df71f 100644 --- a/lib/Doctrine/Table.php +++ b/lib/Doctrine/Table.php @@ -1467,7 +1467,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable */ public function setTableName($tableName) { - $this->_options['tableName'] = $tableName; + $this->setOption('tableName', $this->_conn->formatter->getTableName($tableName)); } /**