From c134ad16cb3ba567c8e88f2a54df7e56876a03e1 Mon Sep 17 00:00:00 2001 From: zYne Date: Tue, 21 Nov 2006 23:35:08 +0000 Subject: [PATCH] Added support for new attributes --- lib/Doctrine/Configurable.php | 18 ++++++++++++++++++ lib/Doctrine/Manager.php | 7 +++++++ 2 files changed, 25 insertions(+) diff --git a/lib/Doctrine/Configurable.php b/lib/Doctrine/Configurable.php index ea877967f..8eeda3ba6 100644 --- a/lib/Doctrine/Configurable.php +++ b/lib/Doctrine/Configurable.php @@ -116,7 +116,25 @@ abstract class Doctrine_Configurable { case Doctrine::ATTR_AUTO_LENGTH_VLD: case Doctrine::ATTR_AUTO_TYPE_VLD: case Doctrine::ATTR_QUERY_LIMIT: + case Doctrine::ATTR_QUOTE_IDENTIFIER: + case Doctrine::ATTR_PORTABILITY: + break; + case Doctrine::ATTR_SEQCOL_NAME: + if( ! is_string($value)) + throw new Doctrine_Exception('Sequence column name attribute only accepts string values'); + + break; + case Doctrine::ATTR_FIELD_CASE: + if($value != 0 && $value != CASE_LOWER && $value != CASE_UPPER) + throw new Doctrine_Exception('Field case attribute should be either 0, CASE_LOWER or CASE_UPPER constant.'); + break; + case Doctrine::ATTR_SEQNAME_FORMAT: + case Doctrine::ATTR_IDXNAME_FORMAT: + if($this instanceof Doctrine_Table) { + throw new Doctrine_Exception('Sequence / index name format attributes cannot be set' + . 'at table level (only at connection or global level).'); + } break; default: throw new Doctrine_Exception("Unknown attribute."); diff --git a/lib/Doctrine/Manager.php b/lib/Doctrine/Manager.php index e8958b254..582e7c10f 100644 --- a/lib/Doctrine/Manager.php +++ b/lib/Doctrine/Manager.php @@ -97,6 +97,11 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera Doctrine::ATTR_AUTO_TYPE_VLD => true, Doctrine::ATTR_CREATE_TABLES => true, Doctrine::ATTR_QUERY_LIMIT => Doctrine::LIMIT_RECORDS, + Doctrine::ATTR_IDXNAME_FORMAT => '%_idx', + Doctrine::ATTR_SEQNAME_FORMAT => '%_seq', + Doctrine::ATTR_QUOTE_IDENTIFIER => false, + Doctrine::ATTR_SEQCOL_NAME => 'id', + Doctrine::ATTR_PORTABILITY => Doctrine::PORTABILITY_ALL, ); foreach($attributes as $attribute => $value) { $old = $this->getAttribute($attribute); @@ -186,6 +191,8 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera case "informix": $this->connections[$name] = new Doctrine_Connection_Informix($this, $adapter); break; + default: + throw new Doctrine_Manager_Exception('Unknown connection driver '. $adapter->getAttribute(PDO::ATTR_DRIVER_NAME)); endswitch;