Welcome Guest, Not a member yet? Register   Sign In
Resetting class variables to defaults

[eluser]Daniel H[/eluser]
I start my models with..


class x_model extends Model {
    // Table name
    var $table = '';
    // Order field name
    var $order_field = array();
    // Limit and offset
    var $limit = NULL;
    var $offset = NULL;
    // Field names in the database table
    var $id = NULL;
    var $name = NULL;
    // etc...

... and then I have a reset() function that looks like this...

function reset()
        // Ensure all the variables are listed here
        $this->id = NULL;
        $this->name = NULL;
        // etc...
        $this->limit = NULL;
        $this->offset = NULL;
        $this->order_field = array();

Instead of listing out all the variables again with their defaults, is there a shorthand which just sets the variables back to their original values?

Many thanks,


try playing around with get_class_vars

[eluser]Daniel H[/eluser]
Perfect - thanks a lot.

Theme © iAndrew 2016 - Forum software by © MyBB