CodeIgniter Forums
DataMapper, save(), and references - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: DataMapper, save(), and references (/showthread.php?tid=47881)



DataMapper, save(), and references - El Forum - 12-26-2011

[eluser]Dracos[/eluser]
I'm in the process of writing a library that manages some aspects of calendar event recurrence. A reference to a DM model instance is passed to the library constructor and stored in a class variable. Later, I use get_copy() on it and try to save a self-relationship of the copy using the reference.

Code:
Class foo_lib {
    private $bar = null;

    public function __construct(&$baz) {
        $this->bar = $baz;
    }

    public function blah() {
        $new_bar = $this->bar->get_copy();
        $new_bar->save(array('some_rel' => $this->bar));
    }
}

$new_bar gets saved, but without the relationship to the original $baz (its some_rel_id is 0). Is this a bug?