Welcome Guest, Not a member yet? Register   Sign In
Global Variable
#5

[eluser]bubbafoley[/eluser]
no no, use $this->q_string to refer to $q_string. It's a member of the Projects_model class so it has to be accessed inside the class with $this.

Code:
class Projects_model extends CI_Model {
    
    private $q_string;
    
        function __construct()
    {
        parent::__construct();
    }
    

    function getProjects()
    {
        $q = $this->db->get('projects','desc');
        $this->q_string="SELECT *  FROM projects ORDER BY prj_year DESC, prj_year_sort ASC";
        $q= $this->db->query($this->q_string);
        if ($q->num_rows() > 0) {
            foreach ($q->result() as $row)
        {
                  $data[] = $row;
        }
      }
      $q->free_result();
      return $data;
  }
  function ooProjects()
  {
      $q= $this->db->query($this->q_string);
      if ($q->num_rows() > 0) {
      }
      return $q;
  }

  function getProjectYears()
  {
    $year_from = $this->input->post(‘year_from’);
    $year_to = $this->input->post(‘year_to’);
    $this->q_string=“SELECT *  FROM projects where prj_year >=”.$year_from.” and prj_year <= “.$year_to.
      ” ORDER BY prj_year DESC, prj_year_sort ASC”;
      $q= $this->db->query($this->q_string);
      if ($q->num_rows() > 0)
      {
        foreach ($q->result() as $row)
        {
          $data[] = $row;
        }
        return $data;
        $q->free_result();
      }
  }


Messages In This Thread
Global Variable - by El Forum - 03-18-2011, 03:14 PM
Global Variable - by El Forum - 03-18-2011, 03:36 PM
Global Variable - by El Forum - 03-18-2011, 04:18 PM
Global Variable - by El Forum - 03-18-2011, 04:53 PM
Global Variable - by El Forum - 03-18-2011, 05:08 PM
Global Variable - by El Forum - 03-18-2011, 06:08 PM
Global Variable - by El Forum - 03-18-2011, 06:13 PM
Global Variable - by El Forum - 03-18-2011, 06:19 PM
Global Variable - by El Forum - 03-18-2011, 06:28 PM
Global Variable - by El Forum - 03-18-2011, 06:39 PM
Global Variable - by El Forum - 03-18-2011, 06:55 PM
Global Variable - by El Forum - 03-18-2011, 07:17 PM
Global Variable - by El Forum - 03-18-2011, 07:28 PM
Global Variable - by El Forum - 03-19-2011, 07:32 AM



Theme © iAndrew 2016 - Forum software by © MyBB