2014-07-17 2 views
-1

에서 데이터를 검색 그래서 나는 오류가 발생합니다.MySQL의 테이블 CodeIgniter의 구문 오류

여기 내 컨트롤러 :

<?php if (! defined('BASEPATH')) exit('No direct script access allowed'); 

class C_view_users extends CI_controller { 

public function __construct(){ 
    parent::__construct(); 

} 

public function index() { 

    $data = array(); 
    $this->load->model('m_users'); 
    //$this->load->library('table'); 
    $data['result'] = $this->m_users->get_contents(); 
    $this->load->view('view_users', $data); 
} 
?> 

및 모델 :

<?php 
class m_claims extends CI_model { 

function __construct() { 
    parent::__construct(); 

    //Get CI Instance 
    //$CI = & get_instance(); 
    //$CI->load->model(EASYPHP_CORE_DIR . 'user_auth' , 'user_auth'); 

    //--------------- Table name, caption and controller --------------- 
    $this->tableName = "users"; 
    $this->caption = "Users"; 
    $this->controllerName = "c_view_users"; 
    $this->recordsPerPage = 25; 


    //--------------- Pages and function setup --------------- 
    $this->add = true; 
    $this->update = true; 
    $this->view = true; 
    $this->printView = true; 
    $this->delete = true; 
    $this->allowQuickSearch = true; 


function get_contents() { 
    $this->db->select('*'); 
    $this->db->from('scouts'); 
    $query = $this->db->get(); 
    return $result = $query->result(); 
} 
} 

} 
}?> 

<table> 
<tr> 
<th>Content</th> 

</tr> 
<?php foreach($result as $r): ?> 
<tr><?php echo $r->content; ?> 

    </tr> 
<?php endforeach; ?> 
</table> 
<?php 

사람이 컨트롤러에 내 오류를 발견 도와 드릴까요? 나는 행운이없는 제거의 과정을 시도했다. 여기에서 내 구문이 옳았다 고 생각했습니다.

+0

이 전체 컨트롤러이다? 당신은 닫는 중괄호'}'를 끝내고 있습니다. –

+0

분명히 저의 날카로운 눈은 그렇게 예리하지 않습니다. 감사. – tkdlax

+0

@tkdlax 당신이'C_view_users' 컨트롤러에'users' 모델을 올려 놓았고'm_claims' 모델 코드를 게시했습니다. 어떤 관계? –

답변

0
이에 모델을 변경

:

<?php 
    class m_claims extends CI_model { 

     function __construct() { 
      parent::__construct(); 

      //Get CI Instance 
      //$CI = & get_instance(); 
      //$CI->load->model(EASYPHP_CORE_DIR . 'user_auth' , 'user_auth'); 

      //--------------- Table name, caption and controller --------------- 
      $this->tableName = "users"; 
      $this->caption = "Users"; 
      $this->controllerName = "c_view_users"; 
      $this->recordsPerPage = 25; 


      //--------------- Pages and function setup --------------- 
      $this->add = true; 
      $this->update = true; 
      $this->view = true; 
      $this->printView = true; 
      $this->delete = true; 
      $this->allowQuickSearch = true; 
     } 

     function get_contents() { 
      $this->db->select('*'); 
      $this->db->from('scouts'); 
      $query = $this->db->get(); 
      return $result = $query->result(); 
     } 
    } 
?> 
+0

재 형식화가 이루어 지지만 실제로 구문 적으로 동일하지 않습니까? 나는 그것을 시도하고 여전히 컨트롤러 구문을 참조하는 동일한 오류가 발생합니다. – tkdlax