public function __construct($table_name, $id = 0, &$db = false) { if ($id > 0) { $this->bean = R::load($table_name, $id); } else { $this->bean = R::dispense($table_name); } $this->table_name = $table_name; $this->db = $db; if ($id > 0) { $this->load($id); } $this->fields = Fm::config('models.' . $table_name); }