Created
November 6, 2013 13:44
-
-
Save jmertic/7336266 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function link_record_beans($bean1, $bean2){ | |
$m1 = $bean1->module_dir; | |
$m2 = $bean2->module_dir; | |
$rel=getRelationshipByModules($m1, $m2); //see link to previous post for this function | |
if($rel !== FALSE){ | |
if($rel[1] == $m1){ | |
$class = $bean1->object_name; | |
$id = $bean1->id; | |
$rel_id = $bean2->id; | |
}elseif($rel[1] == $m2){ | |
$class = $bean2->object_name; | |
$id = $bean2->id; | |
$rel_id = $bean1->id; | |
} | |
$lhs = new $class; | |
$lhs->retrieve($id); | |
$lhs->load_relationship($rel[0]); | |
$lhs->$rel[0]->add($rel_id); | |
$lhs->save(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment