From efc7baa19b02e59cf3f600dbc06a25d2a9a4a7cf Mon Sep 17 00:00:00 2001 From: lsmith Date: Fri, 11 May 2007 19:13:20 +0000 Subject: [PATCH] - use ATTR_DECIMAL_PLACES when defining a decimal field --- lib/Doctrine/DataDict/Firebird.php | 6 +++--- lib/Doctrine/DataDict/Mssql.php | 4 ++-- lib/Doctrine/DataDict/Mysql.php | 5 +++-- lib/Doctrine/DataDict/Oracle.php | 4 ++-- lib/Doctrine/Manager.php | 17 +++++++++-------- 5 files changed, 19 insertions(+), 17 deletions(-) diff --git a/lib/Doctrine/DataDict/Firebird.php b/lib/Doctrine/DataDict/Firebird.php index 9678a2d7d..a18902c42 100644 --- a/lib/Doctrine/DataDict/Firebird.php +++ b/lib/Doctrine/DataDict/Firebird.php @@ -93,9 +93,9 @@ class Doctrine_DataDict_Firebird extends Doctrine_DataDict return 'DOUBLE PRECISION'; case 'decimal': $length = !empty($field['length']) ? $field['length'] : 18; - return 'DECIMAL(' . $length.',' . $this->conn->options['decimal_places'] . ')'; + return 'DECIMAL('.$length.','.$this->conn->getAttribute(Doctrine::ATTR_DECIMAL_PLACES).')'; } - + throw new Doctrine_DataDict_Exception('Unknown field type \'' . $field['type'] . '\'.'); } /** @@ -184,7 +184,7 @@ class Doctrine_DataDict_Firebird extends Doctrine_DataDict return array('type' => $type, 'length' => $length, - 'unsigned' => $unsigned, + 'unsigned' => $unsigned, 'fixed' => $fixed); } /** diff --git a/lib/Doctrine/DataDict/Mssql.php b/lib/Doctrine/DataDict/Mssql.php index ca7e53e3a..4385587fd 100644 --- a/lib/Doctrine/DataDict/Mssql.php +++ b/lib/Doctrine/DataDict/Mssql.php @@ -108,7 +108,7 @@ class Doctrine_DataDict_Mssql extends Doctrine_DataDict return 'FLOAT'; case 'decimal': $length = !empty($field['length']) ? $field['length'] : 18; - return 'DECIMAL('.$length.','.$this->conn->options['decimal_places'].')'; + return 'DECIMAL('.$length.','.$this->conn->getAttribute(Doctrine::ATTR_DECIMAL_PLACES).')'; } throw new Doctrine_DataDict_Exception('Unknown field type \'' . $field['type'] . '\'.'); @@ -181,7 +181,7 @@ class Doctrine_DataDict_Mssql extends Doctrine_DataDict return array('type' => $type, 'length' => $length, - 'unsigned' => $unsigned, + 'unsigned' => $unsigned, 'fixed' => $fixed); } } diff --git a/lib/Doctrine/DataDict/Mysql.php b/lib/Doctrine/DataDict/Mysql.php index 63fda3fb7..963f56dc6 100644 --- a/lib/Doctrine/DataDict/Mysql.php +++ b/lib/Doctrine/DataDict/Mysql.php @@ -216,7 +216,8 @@ class Doctrine_DataDict_Mysql extends Doctrine_DataDict return 'DOUBLE'; case 'decimal': $length = !empty($field['length']) ? $field['length'] : 18; - return 'DECIMAL(' . $length . ',' . 0 . ')'; //$this->dbh->options['decimal_places'] . ')'; +var_dump('DECIMAL('.$length.','.$this->conn->getAttribute(Doctrine::ATTR_DECIMAL_PLACES).')'); + return 'DECIMAL('.$length.','.$this->conn->getAttribute(Doctrine::ATTR_DECIMAL_PLACES).')'; } throw new Doctrine_DataDict_Exception('Unknown field type \'' . $field['type'] . '\'.'); } @@ -246,7 +247,7 @@ class Doctrine_DataDict_Mysql extends Doctrine_DataDict if ( ! isset($field['name'])) { $field['name'] = ''; } - + $values = null; switch ($dbType) { diff --git a/lib/Doctrine/DataDict/Oracle.php b/lib/Doctrine/DataDict/Oracle.php index f97ca182f..1c8eebc14 100644 --- a/lib/Doctrine/DataDict/Oracle.php +++ b/lib/Doctrine/DataDict/Oracle.php @@ -92,7 +92,7 @@ class Doctrine_DataDict_Oracle extends Doctrine_DataDict case 'double': return 'NUMBER'; case 'decimal': - return 'NUMBER(*,'.$this->conn->options['decimal_places'].')'; + return 'NUMBER(*,'.$this->conn->getAttribute(Doctrine::ATTR_DECIMAL_PLACES).')'; default: } throw new Doctrine_DataDict_Exception('Unknown field type \'' . $field['type'] . '\'.'); @@ -188,7 +188,7 @@ class Doctrine_DataDict_Oracle extends Doctrine_DataDict return array('type' => $type, 'length' => $length, - 'unsigned' => $unsigned, + 'unsigned' => $unsigned, 'fixed' => $fixed); } } diff --git a/lib/Doctrine/Manager.php b/lib/Doctrine/Manager.php index 8066375d1..eecd422e7 100644 --- a/lib/Doctrine/Manager.php +++ b/lib/Doctrine/Manager.php @@ -115,6 +115,7 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera Doctrine::ATTR_SEQCOL_NAME => 'id', Doctrine::ATTR_PORTABILITY => Doctrine::PORTABILITY_ALL, Doctrine::ATTR_EXPORT => Doctrine::EXPORT_NONE, + Doctrine::ATTR_DECIMAL_PLACES => 2, ); foreach ($attributes as $attribute => $value) { $old = $this->getAttribute($attribute); @@ -255,9 +256,9 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera return $this->connections[$name]; } - /** + /** * getComponentAlias - * retrieves the alias for given component name + * retrieves the alias for given component name * if the alias couldn't be found, this method returns the given * component name * @@ -269,7 +270,7 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera if (isset($this->componentAliases[$componentName])) { return $this->componentAliases[$componentName]; } - + return $componentName; } /** @@ -281,10 +282,10 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera * @param string $alias * @return Doctrine_Manager */ - public function setComponentAlias($componentName, $alias) + public function setComponentAlias($componentName, $alias) { $this->componentAliases[$componentName] = $alias; - + return $this; } /** @@ -293,7 +294,7 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera * @param Doctrine_Connection $conn connection object to be searched for * @return string the name of the connection */ - public function getConnectionName(Doctrine_Connection $conn) + public function getConnectionName(Doctrine_Connection $conn) { return array_search($conn, $this->connections, true); } @@ -346,7 +347,7 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera public function closeConnection(Doctrine_Connection $connection) { $connection->close(); - + $key = array_search($connection, $this->connections, true); if ($key !== false) { @@ -389,7 +390,7 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera * @param mixed $key the connection key * @return boolean */ - public function contains($key) + public function contains($key) { return isset($this->connections[$key]); }