Zf框架,输入地址总是跳到错误视图!

cnbsd 2012-05-01 09:43:13
AdminController.php //子类继承BaseController.php
<?php
require_once 'BaseController.php';
require_once APPLICATION_PATH.'/models/Tpvotes.php';

class AdminController extends BaseController {
public function indexAction()
{

}
}

BaseController.php //父类

<?php
class BaseController extends Zend_Controller_Action {
public function init()
{
//数据库配置
$url = constant("APPLICATION_PATH").DIRECTORY_SEPARATOR.'configs'.DIRECTORY_SEPARATOR.'application.ini';
$dbconfig = new Zend_Config_ini($url, 'mysql');
$db = Zend_Db::factory($dbconfig->db);
$db->query('set names gb2312');
Zend_Db_Table::setDefaultAdapter($db);
}
}

application.ini //配置文件,只发mysql配置
[mysql]
database.adapter = pdo_mysql
database.params.host = localhost
database.params.username = root
database.params.password = 123456
database.params.dbname = mytp

Tpvotes.php //表模型

<?php
class Tpvotes extends Zend_Db_Table {
protected $_name = 'tp_votes';
}
?>


输入域名/admin/index 跳转到内置错误页面!
...全文
179 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
mcleed 2012-05-11
  • 打赏
  • 举报
回复
应该是你在apache路径中的配置不对
dsfy2011 2012-05-02
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 的回复:]

class BaseController extends Zend_Controller_Action {

然后再

class AdminController extends BaseController {

是不允许的。

常规情况下Controller直接继承Zend_Controller_Action
[/Quote]

你这个说得就不对了吧?一般情况下都是这样用的,直接继承Zend_Controller_Action这个不利于扩展
coder 2012-05-01
  • 打赏
  • 举报
回复
class BaseController extends Zend_Controller_Action {

然后再

class AdminController extends BaseController {

是不允许的。

常规情况下Controller直接继承Zend_Controller_Action
cnbsd 2012-05-01
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 的回复:]

class BaseController extends Zend_Controller_Action {

然后再

class AdminController extends BaseController {

是不允许的。

常规情况下Controller直接继承Zend_Controller_Action
[/Quote]


仍然不行,不知道问题在哪!
修改后的文件 AdminController.php
<?php
require_once APPLICATION_PATH.'/models/Tpvotes.php';

class AdminController extends Zend_Controller_Action {
public function init()
{
$dbconfig = new Zend_config_Ini(APPLICATION_PATH.'/configs/application.ini', 'mysql');
$db = Zend_Db::factory($dbconfig->db);
$db->query('set names gb2312');
Zend_Db_Table::setDefaultAdapter($db);

}
public function addAction()
{
$this->render('add');
}

public function okAction()
{
//获取表单数据
$vote = $this->getRequest()->getParam('vote');
$reference = $this->getRequest()->getParam('reference');
$count = $this->getRequest()->getParam('count');

$data = array('vote'=>$vote, 'reference'=>$reference, 'count'=>$count);
$table = new Tpvotes();
$table->insert($data);
$this->render('ok');
}

}

4,250

社区成员

发帖
与我相关
我的任务
社区描述
国内外优秀PHP框架讨论学习
社区管理员
  • Framework
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧