This commit is contained in:
parent
2d9c165fad
commit
525e7d74a1
@ -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)) {
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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.");
|
||||
}
|
||||
|
@ -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,
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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()) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user