Welcome Guest, Not a member yet? Register   Sign In
Model overwriting other model data
#1

[eluser]Flipside Tech[/eluser]
I have some total weirdness happening with models that share the same member name.

Example:
Code:
class Category_model extends Model {
    protected $id;
    protected $name;
    protected $uri;
    function Category_model() {
        parent::Model();
        $this->init();
    }
    function init() {
    $this->id = 0;
    $this->name = "";
        $this->uri = "";
    }
    function getName() { return $this->name; }
    function setName($str) { $this->name = $str; }
    function getURI() { return $this->uri; }
    function setURI($str) { $this->uri = $str; }    
}
class Post_model extends Model {
    protected $id;
    protected $name;
    protected $uri;
    function Post_model() {
        parent::Model();
        $this->init();
    }
    function init() {
    $this->id = 0;
    $this->name = "";
        $this->uri = "";
    }
    function getName() { return $this->name; }
    function setName($str) { $this->name = $str; }
    function getURI() { return $this->uri; }
    function setURI($str) { $this->uri = $str; }    
}

Ok, simple right. Now in the controller:
Code:
$this->post_model->setURI("post_uri");
echo $this->post_model->getURI();   // outputs post_uri

$this->category_model->setURI("category_uri");
echo $this->category_model->getURI();   // outputs  category_uri

echo $this->post_model->getURI();   // outputs category_uri .... ummmm ... what up?

Weird. Help.


Messages In This Thread
Model overwriting other model data - by El Forum - 12-11-2008, 09:09 PM
Model overwriting other model data - by El Forum - 12-11-2008, 09:20 PM



Theme © iAndrew 2016 - Forum software by © MyBB