Welcome Guest, Not a member yet? Register   Sign In
DataMapper, save(), and references
#1

[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?




Theme © iAndrew 2016 - Forum software by © MyBB