2013-05-08 32 views
2

我的CodeIgniter小型項目(只是爲了熟悉它,它實際上就像他們的教程的例子)它停止工作,給我沒有輸出或錯誤,甚至在index.php文件設置爲研究與開發...CodeIgniter:應用程序不工作,並不會記錄錯誤

所以我試着用一些回聲的

調試它自己,我發現這裏停止記錄

class News extends CI_Controller { 

    public function __construct() 
    { 

     parent::__construct(); 
     echo 'This is echoed'; 
     $this->load->model('news_model'); 
     echo 'This wont be echoed'; 
    } 
     /*(class continues)*/ 
} 

而且我news_model.php看起來像這樣:

<?php 
class News_model extends CI_Model { 

    public function __construct() 
    { 
     $this->load->database(); 
    } 

    public function get_news($slug = FALSE) 
    { 
     if ($slug === FALSE) 
     { 
      $query = $this->db->get('news'{}); 
      return $query->result_array(); 
     } 

     $query = $this->db->get_where('news', array('slug' => $slug)); 
     return $query->row_array(); 
    } 

    public function set_news() 
    { 
     $this->load->helper('url'); 

     $slug = url_title($this->input->post('title'), 'dash', TRUE); 

     $data = array(
      'title' => $this->input->post('title'), 
      'slug' => $slug, 
      'text' => $this->input->post('text') 
     ); 

     return $this->db->insert('news', $data); 
    } 
} 

任何想法我做錯了什麼?

CNC中

public function __construct() 
{ 
    echo '__construct()'; 
    $this->load->database(); 
    echo 'after__construct()'; 
} 

他們都不是迴盪......

+0

是否在News_model構建運行?你有沒有設置你的數據庫參數? – karmafunk 2013-05-08 09:12:59

+0

它不...我添加了我測試的問題 – 2013-05-08 09:15:47

回答

1

找到1

$this->db->get('news'{}); // try to del {} 

第一參數是表名

第二個和第三個參數啓用你設置限制和抵消條款

+0

您能詳細說明一下嗎?我不確定你的意思... – 2013-05-08 09:16:33

+0

@Toni Michel Caubet,嘗試刪除{} – 2013-05-08 09:19:08

0

原始codeignitor教程有這樣的:

public function get_news($slug = FALSE) 
{ 
if ($slug === FALSE) 
{ 
    $query = $this->db->get('news'); // <---------------------------- 
    return $query->result_array(); 
} 

$query = $this->db->get_where('news', array('slug' => $slug)); 
return $query->row_array(); 
} 
+0

另外,如果您使用PHP編輯器,則會突出顯示此錯誤。 – karmafunk 2013-05-08 09:23:05

相關問題