/** * Attaches another object to the object * NB: You must have saved the object you want to attach before attaching * it eg: * <code> * $post = MyActiveRecord::Create('Post'); * $post->populate( 'title'=>'New Post' ); * $post->save(); * $topic->attach('post'); * </code> * * @param object $obj the object you wish to attach * @return boolean True on success. False on failure. */ public function attach(&$obj) { if ($this->id && $obj->id) { return MyActiveRecord::Link($this, $obj); } else { trigger_error('MyActiveRecord::attach() - both objects must be saved before you can attach'); return false; } }