This commit is contained in:
parent
45cb86dab9
commit
1ef946aedb
@ -451,6 +451,7 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
|
|||||||
switch ($this->_table->getIdentifierType()) {
|
switch ($this->_table->getIdentifierType()) {
|
||||||
case Doctrine::IDENTIFIER_AUTOINC:
|
case Doctrine::IDENTIFIER_AUTOINC:
|
||||||
case Doctrine::IDENTIFIER_SEQUENCE:
|
case Doctrine::IDENTIFIER_SEQUENCE:
|
||||||
|
case Doctrine::IDENTIFIER_NATURAL:
|
||||||
$name = $this->_table->getIdentifier();
|
$name = $this->_table->getIdentifier();
|
||||||
|
|
||||||
if ($exists) {
|
if ($exists) {
|
||||||
@ -458,17 +459,6 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
|
|||||||
$this->_id[$name] = $this->_data[$name];
|
$this->_id[$name] = $this->_data[$name];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unset($this->_data[$name]);
|
|
||||||
|
|
||||||
break;
|
|
||||||
case Doctrine::IDENTIFIER_NATURAL:
|
|
||||||
$this->_id = array();
|
|
||||||
$name = $this->_table->getIdentifier();
|
|
||||||
|
|
||||||
if (isset($this->_data[$name]) && $this->_data[$name] !== self::$_null) {
|
|
||||||
$this->_id[$name] = $this->_data[$name];
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case Doctrine::IDENTIFIER_COMPOSITE:
|
case Doctrine::IDENTIFIER_COMPOSITE:
|
||||||
$names = $this->_table->getIdentifier();
|
$names = $this->_table->getIdentifier();
|
||||||
@ -1170,13 +1160,24 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
|
|||||||
*/
|
*/
|
||||||
public function copy()
|
public function copy()
|
||||||
{
|
{
|
||||||
$ret = $this->_table->create($this->_data);
|
$data = $this->_data;
|
||||||
|
|
||||||
|
if ($this->_table->getIdentifierType() === Doctrine::IDENTIFIER_AUTOINC) {
|
||||||
|
$id = $this->_table->getIdentifier();
|
||||||
|
|
||||||
|
unset($data[$id]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$ret = $this->_table->create($data);
|
||||||
$modified = array();
|
$modified = array();
|
||||||
foreach ($this->_data as $key => $val) {
|
|
||||||
|
foreach ($data as $key => $val) {
|
||||||
if ( ! ($val instanceof Doctrine_Null)) {
|
if ( ! ($val instanceof Doctrine_Null)) {
|
||||||
$ret->_modified[] = $key;
|
$ret->_modified[] = $key;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@ -1219,8 +1220,8 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
|
|||||||
$this->_modified = array();
|
$this->_modified = array();
|
||||||
} else {
|
} else {
|
||||||
$name = $this->_table->getIdentifier();
|
$name = $this->_table->getIdentifier();
|
||||||
|
|
||||||
$this->_id[$name] = $id;
|
$this->_id[$name] = $id;
|
||||||
|
$this->_data[$name] = $id;
|
||||||
$this->_state = Doctrine_Record::STATE_CLEAN;
|
$this->_state = Doctrine_Record::STATE_CLEAN;
|
||||||
$this->_modified = array();
|
$this->_modified = array();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user