Skip to content

Commit

Permalink
add copy method
Browse files Browse the repository at this point in the history
  • Loading branch information
imsamurai committed Feb 3, 2014
1 parent e1d6479 commit c48cfa0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .semver
@@ -1,5 +1,5 @@
---
:major: 1
:minor: 0
:patch: 2
:patch: 3
:special: ''
12 changes: 12 additions & 0 deletions Lib/ActiveRecord/ActiveRecord.php
Expand Up @@ -336,6 +336,18 @@ public function save() {
public function jsonSerialize() {
return $this->_Record;
}

/**
* Copy record without associations and primary key
*
* @return ActiveRecord
*/
public function copy() {
$that = $this->getModel()->createActiveRecord(
array($this->getModel()->primaryKey => null) + $this->_Record
);
return $that;
}

protected function _saveBelongsTo() {
foreach ($this->_associations as $Association) {
Expand Down

0 comments on commit c48cfa0

Please sign in to comment.