0

This is somewhat related to [CodeIgniter active records' problems calling multiple stored procedures

but I am not experiencing a blank page; instead when I am passing my data array to view it seems that the the preceding array also being drag to the view.

model

  public function data1($student) {
            $year = 1;
            $sem = 1;

            $course = $this->getStudentCourseByStudentId($student);
            $sql = "CALL EVALUATION_BY_YEAR_SEM(?,?,?,?)";

            $query = $this->db->query($sql, array($course, $student, $year, $sem));

            if (!$query) {
                return  $this->db->error();
            } else {
                mysqli_next_result( $this->db->conn_id );
                return $query->result();
            }
        }

  public function data2($student) {
            $year = 1;
            $sem = 2;

            $course = $this->getStudentCourseByStudentId($student);

            $sql = "CALL EVALUATION_BY_YEAR_SEM(?,?,?,?)";

            $query = $this->db->query($sql,array($course,$student,$year,$sem));

            if (!$query) {
                return  $this->db->error();
            } else {
                mysqli_next_result( $this->db->conn_id );
                return $query->result();
            }
       }

Controller:

$data['data1']=data1 from my model(SP);
$data['data2']=data2 from my model(SP);

View:

foreach($data2 as key => $value ) {
    echo ....;
}

Here's the PROBLEM... in the view, I only wanted to output the $data2 but to my surprise $data1 is also being output.

Does anybody else have this issue?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
oscar1925
  • 25
  • 10

1 Answers1

1

I JUST SOLVE IT.

Model

public function data1($student){
  **$this->db->initialize();**
  $year = 1;$sem = 1;
  $course = $this->getStudentCourseByStudentId($student);
  $sql = "CALL EVALUATION_BY_YEAR_SEM(?,?,?,?)";
  $query = $this->db->query($sql,array($course,$student,$year,$sem));
  if (!$query) {
  return  $this->db->error();
  }else {
  mysqli_next_result( $this->db->conn_id );
  return $query->result();**$this->db->close();**
  }
  }
      public function data2($student){
      **$this->db->initialize();**
      $year = 1;$sem = 2;
      $course = $this->getStudentCourseByStudentId($student);
      $sql = "CALL EVALUATION_BY_YEAR_SEM(?,?,?,?)";
      $query = $this->db->query($sql,array($course,$student,$year,$sem));
      if (!$query) {
      return  $this->db->error();
      }else {
      mysqli_next_result( $this->db->conn_id );
      return $query->result();**$this->db->close();**
      }
      }

controller

$data['data1']=data1 from my model(SP);
**$this->db->close();**
$data['data2']=data2 from my model(SP);
oscar1925
  • 25
  • 10