2011-04-17 117 views
0

我想在我的WAMP上用PHP 5.3.5和2.0.2 CI設置CodeIgniter。我的「Hello World」應用程序成功運行(我只有一個控制器和視圖)。接下來,我添加了一個型號test.php的codeigniter中的時區設置問題

class Tests extends CI_Model { 

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

我實例化模型在我的控制器:

$this->load->model('Tests'); 

但我不斷收到此錯誤:enter image description here

It is not safe to rely on the system's timezone settings.

如何解決這個錯誤?我試着在php.ini中設置date.timezone屬性。我也嘗試在CI的index.php中調用date_default_timezone_set方法。我確實通過CI論壇,但似乎每個人都通過呼籲date_default_timezone_set解決了這個問題。但是當我調用這個方法的時候,我甚至不知道這個錯誤。相反,我得到一個來自Apache的500服務器錯誤響應!

PHP & CI專家..我需要你的幫助。


最新

我啓用了日誌記錄看東西墊下的運行方式。這裏是我的模型:

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

    class Hello extends CI_Model { 

     function __construct() 
     { 
      log_message('debug', "Staring Hello Model"); 
      parent::__construct(); 
      log_message('debug', "Done with Hello Model"); 
     } 
    } 

我的控制器:

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

class Hello extends CI_Controller { 

    public function index() 
    { 
     //$this->load->view('hello'); 
     echo phpinfo(); 
    } 

    public function newfun() 
    { 
     log_message('debug', "Starting new method..."); 
     $this->load->model('hello'); 
     log_message('debug', "Completed model load..."); 
     $this->load->view('hello'); 
    } 
} 

而且我的日誌文件:

DEBUG - 2011-04-18 15:01:44 --> Config Class Initialized 
DEBUG - 2011-04-18 15:01:44 --> Hooks Class Initialized 
DEBUG - 2011-04-18 15:01:44 --> Utf8 Class Initialized 
DEBUG - 2011-04-18 15:01:44 --> UTF-8 Support Enabled 
DEBUG - 2011-04-18 15:01:44 --> URI Class Initialized 
DEBUG - 2011-04-18 15:01:44 --> Router Class Initialized 
DEBUG - 2011-04-18 15:01:44 --> Output Class Initialized 
DEBUG - 2011-04-18 15:01:44 --> Security Class Initialized 
DEBUG - 2011-04-18 15:01:44 --> Input Class Initialized 
DEBUG - 2011-04-18 15:01:44 --> Global POST and COOKIE data sanitized 
DEBUG - 2011-04-18 15:01:44 --> Language Class Initialized 
DEBUG - 2011-04-18 15:01:44 --> Loader Class Initialized 
DEBUG - 2011-04-18 15:01:44 --> Controller Class Initialized 
DEBUG - 2011-04-18 15:01:44 --> Starting new method... 
DEBUG - 2011-04-18 15:01:44 --> Model Class Initialized 

最後的日誌輸出來自Model.php的CI構造函數/系統/核心文件夾。沒有跡象表明我的模型控制器正在執行(我沒有看到模型中的任何日誌消息)。

我的模型有什麼問題?我是否正確地編碼或忽略了一些愚蠢的東西?

+0

您的模型中是否有代碼調用任何日期函數?你能粘貼整個構造代碼嗎? – Chris 2011-04-17 12:52:05

+0

我提供了完整的代碼!除構造函數外,沒有任何屬性或方法。我打算稍後使用模型從數據庫中獲取數據... – 2011-04-17 14:06:23

+0

哇,這很奇怪!如果你刪除了parent :: _構造代碼會發生什麼? – Chris 2011-04-18 10:14:07

回答

1

這可能是一個命名衝突?或命名問題(CI在模型/控制器和視圖名稱中使用小寫大寫字母非常具體)。

你可以嘗試'goodbye_model.php'(小寫)和模型'class Goodbye_model擴展CI_Model'的主線並加載'Goodbye_model'(大寫第一個)。

並確保文件名是小寫,類名是第一個大寫。

+0

是的..感謝您的幫助..這是一個命名衝突 – 2011-04-18 11:25:56

+0

不是一個問題,與項目的其餘部分祝你好運 – Chris 2011-04-18 11:26:31