diff --git a/lib/Doctrine/Configurable.php b/lib/Doctrine/Configurable.php index 3966b6608..add34bf22 100644 --- a/lib/Doctrine/Configurable.php +++ b/lib/Doctrine/Configurable.php @@ -64,12 +64,6 @@ abstract class Doctrine_Configurable public function setAttribute($attribute,$value) { switch ($attribute) { - case Doctrine::ATTR_BATCH_SIZE: - if ($value < 0) { - throw new Doctrine_Exception("Batch size should be greater than or equal to zero"); - } - break; - case Doctrine::ATTR_FETCHMODE: if ($value < 0) { throw new Doctrine_Exception("Unknown fetchmode. See Doctrine::FETCH_* constants."); @@ -122,6 +116,15 @@ abstract class Doctrine_Configurable throw new Doctrine_Exception("Couldn't set collection key attribute. No such column '$value'"); } break; + case Doctrine::ATTR_DQL_CACHE: + case Doctrine::ATTR_DQL_PARSER_CACHE: + case Doctrine::ATTR_SQL_CACHE: + if ($value !== null) { + if ( ! ($value instanceof Doctrine_Cache_Interface)) { + throw new Doctrine_Exception('Cache driver should implement Doctrine_Cache_Interface'); + } + } + break; case Doctrine::ATTR_VLD: case Doctrine::ATTR_AUTO_LENGTH_VLD: case Doctrine::ATTR_AUTO_TYPE_VLD: @@ -225,8 +228,9 @@ abstract class Doctrine_Configurable { $attribute = (int) $attribute; - if ($attribute < 0) + if ($attribute < 0) { throw new Doctrine_Exception('Unknown attribute.'); + } if ( ! isset($this->attributes[$attribute])) { if (isset($this->parent)) { diff --git a/lib/Doctrine/Connection.php b/lib/Doctrine/Connection.php index d6874de5a..8d3a92ea6 100644 --- a/lib/Doctrine/Connection.php +++ b/lib/Doctrine/Connection.php @@ -689,7 +689,7 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun if ( ! empty($params)) { $stmt = $this->dbh->prepare($query); $stmt->execute($params); - return $stmt; + return $stmt; } else { return $this->dbh->query($query); } diff --git a/lib/Doctrine/Hydrate.php b/lib/Doctrine/Hydrate.php index c62848f52..8577daa5a 100644 --- a/lib/Doctrine/Hydrate.php +++ b/lib/Doctrine/Hydrate.php @@ -374,7 +374,6 @@ class Doctrine_Hydrate $stmt = $this->conn->execute($query, $params); $array = (array) $this->parseData($stmt); - if (empty($this->_aliasMap)) { throw new Doctrine_Hydrate_Exception("Couldn't execute query. Component alias map was empty."); } diff --git a/lib/Doctrine/Manager.php b/lib/Doctrine/Manager.php index 4d1899c58..43dea4ed5 100644 --- a/lib/Doctrine/Manager.php +++ b/lib/Doctrine/Manager.php @@ -100,9 +100,9 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera if ( ! $init) { $init = true; $attributes = array( - Doctrine::ATTR_FETCHMODE => Doctrine::FETCH_IMMEDIATE, - Doctrine::ATTR_BATCH_SIZE => 5, - Doctrine::ATTR_COLL_LIMIT => 5, + Doctrine::ATTR_DQL_PARSER_CACHE => null, + Doctrine::ATTR_DQL_CACHE => null, + Doctrine::ATTR_SQL_CACHE => null, Doctrine::ATTR_LISTENER => new Doctrine_EventListener(), Doctrine::ATTR_LOCKMODE => 1, Doctrine::ATTR_VLD => false, diff --git a/lib/Doctrine/Query.php b/lib/Doctrine/Query.php index 774fa9187..ffa9bfff7 100644 --- a/lib/Doctrine/Query.php +++ b/lib/Doctrine/Query.php @@ -72,9 +72,9 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable * @var array $_options an array of options */ protected $_options = array( - 'fetchMode' => Doctrine::FETCH_RECORD, - 'cacheMode' => Doctrine::CACHE_NONE, - 'cache' => false, + 'fetchMode' => Doctrine::FETCH_RECORD, + 'parserCache' => false, + 'resultSetCache' => false, ); /** * @var array $_dqlParts an array containing all DQL query parts @@ -249,7 +249,7 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable } else { $this->_dqlParts[$queryPartName] = array($queryPart); } - if ($this->_options['cache'] === Doctrine::CACHE_NONE) { + if ($this->_options['resultSetCache'] || $this->_options['parserCache']) { $this->getParser($queryPartName)->parse($queryPart); } @@ -585,17 +585,13 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable public function getQuery($params = array()) { // check if parser cache is on - if ($this->_options['cacheMode'] === Doctrine::CACHE_PARSER) { - if ( ! $this->_options['cache']) { - throw new Doctrine_Query_Exception('Cache not availible. Use setOption() for setting the cache container.'); - } - + if ($this->_options['parserCache'] !== false) { $dql = $this->getDql(); // calculate hash for dql query $hash = strlen($dql) . md5($dql); // check if cache has sql equivalent for given hash - $sql = $this->_options['cache']->fetch($hash, true); + $sql = $this->_options['parserCache']->fetch($hash, true); if ($sql !== null) { return $sql; } @@ -691,8 +687,8 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable } // append sql query into cache - if ($this->_options['cacheMode'] === Doctrine::CACHE_PARSER) { - $this->_options['cache']->save($hash, $q); + if ($this->_options['parserCache'] !== false) { + $this->_options['parserCache']->save($hash, $q); } return $q; } diff --git a/lib/Doctrine/Record.php b/lib/Doctrine/Record.php index de848d226..4ec7fe50d 100644 --- a/lib/Doctrine/Record.php +++ b/lib/Doctrine/Record.php @@ -346,8 +346,9 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite foreach ($this->_data as $column => $value) { $default = $this->_table->getDefaultValueOf($column); - if ($default === null) + if ($default === null) { $default = self::$_null; + } if ($value === self::$_null || $overwrite) { $this->_data[$column] = $default; @@ -790,7 +791,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite case Doctrine_Record::STATE_TCLEAN: $this->_state = Doctrine_Record::STATE_TDIRTY; break; - }; + } } } else { try { @@ -886,7 +887,6 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite $conn = $this->_table->getConnection(); } $conn->beginTransaction(); - $saveLater = $conn->unitOfWork->saveRelated($this); if ($this->isValid()) {