CI 묻고 답하기

제목 controller와 model-query 질문입니다.
글쓴이 ryuppp 작성시각 2012/12/21 11:37:17
댓글 : 3 추천 : 0 스크랩 : 0 조회수 : 13647   RSS
아래 코드들을 돌려보면 다음과 같은 에러가 납니다.
Parse error: syntax error, unexpected '->' (T_OBJECT_OPERATOR) in /Applications/MAMP/htdocs/ian/mylink/app/models/reports_model.php on line 137

아래 있는 model-select qeury부분은 mysql 에서 문제없이 돌아가는 query 인데요, 이렇게 에러가 나니
뭐가 문젠지 잘 모르겠습니다.  전에도 비슷한 에러가 있긴 했었는데...(line 137은 아래 model의 첫번째 where부분입니다.)
조언 부탁드립니다.

controller
public function app_stats()
  {
   $program = $this->input->get('program', TRUE);
   $term_id = $this->input->get('term', TRUE);
   
   if(!$program){
    $program = "English";
   }

   if(!$term_id){
    $term_id = '20125';
   }

   $this->load->model('reports_model');
   $applications = $this->reports_model->app_stats($program, $term_id);

   foreach ($applications as $apps){
    $apps[] = $apps;
   }

   $this->load->view('header');
   $this->load->view('navigation');
   $this->load->view('reports/app_stats', compact('apps', 'program', 'term_id'));
   $this->load->view('footer');
  }
view
Created Applications Total <?php echo $app_stats['created']; ?> | 
 In Progress Applications <?php echo $app_stats['in_progress']; ?> | 
 Submitted Applications <?php echo $app_stats['submitted']; ?>
 
 <table border="1">
  <tr>
   <th>To Date</th>
   <th>Application ID</th>
   <th>Full Name</th>
   <th>Semester Name</th>
  </tr>

  <?php foreach($apps as $ap):?>
  <tr>
   <td><?php echo $ap['id'];?></td>
   <td><?php echo $ap['full_name'];?></td>
   <td><?php echo $ap['name'];?></td>
  </tr>
 <?php endforeach;?>
 </table>

 그리고 마지막 model 입니다. 

  public function app_stats($program = null, $term_id = null)
  {
   if($program === null || $term_id === null)
   {
    throw new Exception("No program or semester given");
   }
   $app_stats = $this->db->select('application.id, program_emphasis.full_name, term.name')
      ->from('application')
      ->join('map_transition', 'map_transition.id = application.map_transition_id')
      ->join('map', 'map.id = map_transition.map_id')
      ->join('map_conceptual', 'map_conceptual.id = map.map_conceptual_id')
      ->join('program_emphasis', 'program_emphasis.id = map_conceptual.program_emphasis_id' )
      ->join('term', 'term.id = application.term_id');
      ->where('program_emphasis.name', $program) //여기가 에러에 나온 line 137 입니다.
      ->where('term.id', $term_id);
      ->order_by('program_emphasis.name', 'asc')
      ->get()->result_array();

   return $app_stats;
  }
Where 구문이 문제라는데...사실 잘 작동하는 query를 옮긴거라 어떤 문제인지 잘 못찾겠습니다. 
사실 view는 아직 미완성이고 거기까지 진행도 안되는 것 같은데 그래도 혹시나 올려봅니다. 
감사합니다. 

 다음글 ci 에서 ajax 사용시 [초보ㅡㅡ;] (4)
 이전글 CI SESSION 질문입니다. (1)

댓글

헛발이 / 2012/12/21 11:51:56 / 추천 0
;  때문에 그런거 아닌가요?
한대승(불의회상) / 2012/12/21 12:56:53 / 추천 0
헛발이님 말대로

->join('term', 'term.id = application.term_id');
이부분을
->join('term', 'term.id = application.term_id')
이렇게 수정 하세요.
ryuppp / 2012/12/22 01:51:18 / 추천 0
 아....정말 초보라 이런실수를 하는군요...
자바나 다른 쪽에 익숙해 있다보니...

답변 주신 헛발이님, 불의 회상님 감사합니다.!!