Commit 525e7d74 authored by zYne's avatar zYne

--no commit message

--no commit message
parent 2d9c165f
...@@ -64,12 +64,6 @@ abstract class Doctrine_Configurable ...@@ -64,12 +64,6 @@ abstract class Doctrine_Configurable
public function setAttribute($attribute,$value) public function setAttribute($attribute,$value)
{ {
switch ($attribute) { 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: case Doctrine::ATTR_FETCHMODE:
if ($value < 0) { if ($value < 0) {
throw new Doctrine_Exception("Unknown fetchmode. See Doctrine::FETCH_* constants."); throw new Doctrine_Exception("Unknown fetchmode. See Doctrine::FETCH_* constants.");
...@@ -122,6 +116,15 @@ abstract class Doctrine_Configurable ...@@ -122,6 +116,15 @@ abstract class Doctrine_Configurable
throw new Doctrine_Exception("Couldn't set collection key attribute. No such column '$value'"); throw new Doctrine_Exception("Couldn't set collection key attribute. No such column '$value'");
} }
break; 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_VLD:
case Doctrine::ATTR_AUTO_LENGTH_VLD: case Doctrine::ATTR_AUTO_LENGTH_VLD:
case Doctrine::ATTR_AUTO_TYPE_VLD: case Doctrine::ATTR_AUTO_TYPE_VLD:
...@@ -225,8 +228,9 @@ abstract class Doctrine_Configurable ...@@ -225,8 +228,9 @@ abstract class Doctrine_Configurable
{ {
$attribute = (int) $attribute; $attribute = (int) $attribute;
if ($attribute < 0) if ($attribute < 0) {
throw new Doctrine_Exception('Unknown attribute.'); throw new Doctrine_Exception('Unknown attribute.');
}
if ( ! isset($this->attributes[$attribute])) { if ( ! isset($this->attributes[$attribute])) {
if (isset($this->parent)) { if (isset($this->parent)) {
......
...@@ -689,7 +689,7 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun ...@@ -689,7 +689,7 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
if ( ! empty($params)) { if ( ! empty($params)) {
$stmt = $this->dbh->prepare($query); $stmt = $this->dbh->prepare($query);
$stmt->execute($params); $stmt->execute($params);
return $stmt; return $stmt;
} else { } else {
return $this->dbh->query($query); return $this->dbh->query($query);
} }
......
...@@ -374,7 +374,6 @@ class Doctrine_Hydrate ...@@ -374,7 +374,6 @@ class Doctrine_Hydrate
$stmt = $this->conn->execute($query, $params); $stmt = $this->conn->execute($query, $params);
$array = (array) $this->parseData($stmt); $array = (array) $this->parseData($stmt);
if (empty($this->_aliasMap)) { if (empty($this->_aliasMap)) {
throw new Doctrine_Hydrate_Exception("Couldn't execute query. Component alias map was empty."); throw new Doctrine_Hydrate_Exception("Couldn't execute query. Component alias map was empty.");
} }
......
...@@ -100,9 +100,9 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera ...@@ -100,9 +100,9 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera
if ( ! $init) { if ( ! $init) {
$init = true; $init = true;
$attributes = array( $attributes = array(
Doctrine::ATTR_FETCHMODE => Doctrine::FETCH_IMMEDIATE, Doctrine::ATTR_DQL_PARSER_CACHE => null,
Doctrine::ATTR_BATCH_SIZE => 5, Doctrine::ATTR_DQL_CACHE => null,
Doctrine::ATTR_COLL_LIMIT => 5, Doctrine::ATTR_SQL_CACHE => null,
Doctrine::ATTR_LISTENER => new Doctrine_EventListener(), Doctrine::ATTR_LISTENER => new Doctrine_EventListener(),
Doctrine::ATTR_LOCKMODE => 1, Doctrine::ATTR_LOCKMODE => 1,
Doctrine::ATTR_VLD => false, Doctrine::ATTR_VLD => false,
......
...@@ -72,9 +72,9 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable ...@@ -72,9 +72,9 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable
* @var array $_options an array of options * @var array $_options an array of options
*/ */
protected $_options = array( protected $_options = array(
'fetchMode' => Doctrine::FETCH_RECORD, 'fetchMode' => Doctrine::FETCH_RECORD,
'cacheMode' => Doctrine::CACHE_NONE, 'parserCache' => false,
'cache' => false, 'resultSetCache' => false,
); );
/** /**
* @var array $_dqlParts an array containing all DQL query parts * @var array $_dqlParts an array containing all DQL query parts
...@@ -249,7 +249,7 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable ...@@ -249,7 +249,7 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable
} else { } else {
$this->_dqlParts[$queryPartName] = array($queryPart); $this->_dqlParts[$queryPartName] = array($queryPart);
} }
if ($this->_options['cache'] === Doctrine::CACHE_NONE) { if ($this->_options['resultSetCache'] || $this->_options['parserCache']) {
$this->getParser($queryPartName)->parse($queryPart); $this->getParser($queryPartName)->parse($queryPart);
} }
...@@ -585,17 +585,13 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable ...@@ -585,17 +585,13 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable
public function getQuery($params = array()) public function getQuery($params = array())
{ {
// check if parser cache is on // check if parser cache is on
if ($this->_options['cacheMode'] === Doctrine::CACHE_PARSER) { if ($this->_options['parserCache'] !== false) {
if ( ! $this->_options['cache']) {
throw new Doctrine_Query_Exception('Cache not availible. Use setOption() for setting the cache container.');
}
$dql = $this->getDql(); $dql = $this->getDql();
// calculate hash for dql query // calculate hash for dql query
$hash = strlen($dql) . md5($dql); $hash = strlen($dql) . md5($dql);
// check if cache has sql equivalent for given hash // 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) { if ($sql !== null) {
return $sql; return $sql;
} }
...@@ -691,8 +687,8 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable ...@@ -691,8 +687,8 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable
} }
// append sql query into cache // append sql query into cache
if ($this->_options['cacheMode'] === Doctrine::CACHE_PARSER) { if ($this->_options['parserCache'] !== false) {
$this->_options['cache']->save($hash, $q); $this->_options['parserCache']->save($hash, $q);
} }
return $q; return $q;
} }
......
...@@ -346,8 +346,9 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite ...@@ -346,8 +346,9 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
foreach ($this->_data as $column => $value) { foreach ($this->_data as $column => $value) {
$default = $this->_table->getDefaultValueOf($column); $default = $this->_table->getDefaultValueOf($column);
if ($default === null) if ($default === null) {
$default = self::$_null; $default = self::$_null;
}
if ($value === self::$_null || $overwrite) { if ($value === self::$_null || $overwrite) {
$this->_data[$column] = $default; $this->_data[$column] = $default;
...@@ -790,7 +791,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite ...@@ -790,7 +791,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
case Doctrine_Record::STATE_TCLEAN: case Doctrine_Record::STATE_TCLEAN:
$this->_state = Doctrine_Record::STATE_TDIRTY; $this->_state = Doctrine_Record::STATE_TDIRTY;
break; break;
}; }
} }
} else { } else {
try { try {
...@@ -886,7 +887,6 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite ...@@ -886,7 +887,6 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
$conn = $this->_table->getConnection(); $conn = $this->_table->getConnection();
} }
$conn->beginTransaction(); $conn->beginTransaction();
$saveLater = $conn->unitOfWork->saveRelated($this); $saveLater = $conn->unitOfWork->saveRelated($this);
if ($this->isValid()) { if ($this->isValid()) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment