Welcome Guest, Not a member yet? Register   Sign In
access variable from different method within same model class
#2

[eluser]Krzemo[/eluser]
Code:
// this is a model class
class Holiday_model extends Model
{
  var $sql;

  function Holiday_model()
  {
      parent::Model();
      $this->load->database(‘holiday’, TRUE);
  }

  function view_package()
  {
      $this->sql = “select * from package_details”;
      $query = $this->db->query($this->sql);
      return $query->result_array();
  }

  function get_package_details($id)
  {
      $new_sql = $this->sql;//please write here the code

      $row =  $new_sql.” where id = ‘$id’”;
    
      $query = $this->db->query($row);
      return $query->row_array();
  }

}
?>
I'd dont see any point in doing it this way. IMHO it only complicates the code and makes it harder to maintain.


Messages In This Thread
access variable from different method within same model class - by El Forum - 11-05-2009, 04:14 AM



Theme © iAndrew 2016 - Forum software by © MyBB