Commit 7f5844d1 authored by doctrine's avatar doctrine

Doctrine_Record_Exception: better handling of error messages

parent 9c34cb29
...@@ -273,8 +273,6 @@ class Doctrine_Hydrate extends Doctrine_Access { ...@@ -273,8 +273,6 @@ class Doctrine_Hydrate extends Doctrine_Access {
return $this->hydrateHolders($array); return $this->hydrateHolders($array);
} }
$colls = array();
foreach($array as $data) { foreach($array as $data) {
/** /**
* remove duplicated data rows and map data into objects * remove duplicated data rows and map data into objects
......
...@@ -491,7 +491,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite ...@@ -491,7 +491,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
$this->prepareIdentifiers(); $this->prepareIdentifiers();
if($this->id != $old) if($this->id != $old)
throw new Doctrine_Record_Exception(); throw new Doctrine_Record_Exception("The refreshed primary key doesn't match the one in the record memory.", Doctrine::ERR_REFRESH);
$this->state = Doctrine_Record::STATE_CLEAN; $this->state = Doctrine_Record::STATE_CLEAN;
$this->modified = array(); $this->modified = array();
...@@ -679,7 +679,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite ...@@ -679,7 +679,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
case Doctrine_Relation::MANY_AGGREGATE: case Doctrine_Relation::MANY_AGGREGATE:
// one-to-many relation found // one-to-many relation found
if( ! ($value instanceof Doctrine_Collection)) if( ! ($value instanceof Doctrine_Collection))
throw new Doctrine_Exception("Couldn't call Doctrine::set(), second argument should be an instance of Doctrine_Collection when setting one-to-many references."); throw new Doctrine_Record_Exception("Couldn't call Doctrine::set(), second argument should be an instance of Doctrine_Collection when setting one-to-many references.");
$value->setReference($this,$fk); $value->setReference($this,$fk);
break; break;
...@@ -687,7 +687,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite ...@@ -687,7 +687,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
case Doctrine_Relation::ONE_AGGREGATE: case Doctrine_Relation::ONE_AGGREGATE:
// one-to-one relation found // one-to-one relation found
if( ! ($value instanceof Doctrine_Record)) if( ! ($value instanceof Doctrine_Record))
throw new Doctrine_Exception("Couldn't call Doctrine::set(), second argument should be an instance of Doctrine_Record when setting one-to-one references."); throw new Doctrine_Record_Exception("Couldn't call Doctrine::set(), second argument should be an instance of Doctrine_Record when setting one-to-one references.");
if($fk->getLocal() == $this->table->getIdentifier()) { if($fk->getLocal() == $this->table->getIdentifier()) {
$this->references[$name]->set($fk->getForeign(),$this); $this->references[$name]->set($fk->getForeign(),$this);
...@@ -700,7 +700,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite ...@@ -700,7 +700,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
} elseif($fk instanceof Doctrine_Association) { } elseif($fk instanceof Doctrine_Association) {
// join table relation found // join table relation found
if( ! ($value instanceof Doctrine_Collection)) if( ! ($value instanceof Doctrine_Collection))
throw new Doctrine_Exception("Couldn't call Doctrine::set(), second argument should be an instance of Doctrine_Collection when setting one-to-many references."); throw new Doctrine_Record_Exception("Couldn't call Doctrine::set(), second argument should be an instance of Doctrine_Collection when setting one-to-many references.");
} }
$this->references[$name] = $value; $this->references[$name] = $value;
......
<?php <?php
Doctrine::autoload('Doctrine_Exception'); Doctrine::autoload('Doctrine_Exception');
/**
* thrown when Doctrine_Record is refreshed and the refreshed primary key doens't match the old one class Doctrine_Record_Exception extends Doctrine_Exception { }
*/
class Doctrine_Record_Exception extends Doctrine_Exception {
public function __construct() {
parent::__construct("The refreshed primary key doesn't match the
one in the record memory.", Doctrine::ERR_REFRESH);
}
}
?> ?>
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