我遇到以下情况:
class User extends MY_Controller {
(...)
}
class Game extends User {
(...)
}
其中类Game处理userinteractions / ajax请求等,而类User更适用于会话,db交互等(在类Game中我指的是父控制器的某些方法)。 如果我在当地工作,一切都很好。但是在服务器环境中使用相同的星座,我没有得到Game类的任何响应。 (我在config中自动加载类 - 似乎找到了类本身)。但反应总是空洞的。另一方面,我也没有任何错误...所以我问自己问题可能是什么?
我忘记了什么设置? 或者我完全错误的轨道,我不能只是简单地扩展任何控制器?
(抱歉,我对CI很陌生)
提前致谢。
答案 0 :(得分:0)
通常在CodeIgniter中,每个都有一个单独的控制器。所以,你有一个Users
控制器和一个Game
控制器。
当您需要对用户执行某些操作时,您可以调用http://example.com/index.php/users/some_user_action
之类的网址,同样适用于游戏(http://example.com/index.php/game/some_game_action
)。
控制器可能看起来像
// codeigniter/application/controllers/users.php
class Users extends CI_Controller{
function index(){
echo "I'm the index page and can be reached at http://example.com/index.php/users";
}
function some_user_action(){
echo "I'm some user action; see me at http://example.com/index.php/users/some_user_action";
}
}
// codeigniter/application/controllers/game.php
class Game extends CI_Controller{
function index(){
echo "I'm the Game controller index page and can be reached at http://example.com/index.php/game";
}
function some_game_action(){
echo "I'm some game action; see me at http://example.com/index.php/game/some_user_action";
}
}
CodeIgniter有很好的文档;值得一看。介绍教程是一个很好的起点:http://ellislab.com/codeigniter/user-guide/tutorial/index.html另请参阅控制器页面:http://ellislab.com/codeigniter/user-guide/general/controllers.html