Welcome Guest, Not a member yet? Register   Sign In
Vars in models
#2

[eluser]zwippie[/eluser]
I don't think the class variables are really necessary.

From the same Blogmodel example in the userguide:
Code:
function insert_entry()
    {
        $this->title   = $_POST['title'];
        $this->content = $_POST['content'];
        $this->date    = time();

        $this->db->insert('entries', $this);
    }
Can also be achieved without the class variables:
Code:
function insert_entry()
    {
        $data = new stdClass();
        $data->title   = $_POST['title'];
        $data->content = $_POST['content'];
        $data->date    = time();

        $this->db->insert('entries', $data);
    }
However, more sophisticated ActiveRecord models sometimes make uses of the class variables for each field in the database.


Messages In This Thread
Vars in models - by El Forum - 02-10-2008, 01:46 PM
Vars in models - by El Forum - 02-11-2008, 07:43 AM
Vars in models - by El Forum - 02-11-2008, 08:13 AM
Vars in models - by El Forum - 02-11-2008, 10:06 AM
Vars in models - by El Forum - 02-11-2008, 02:25 PM



Theme © iAndrew 2016 - Forum software by © MyBB