/*
初学framework用的是zendframework1.11.10版本,按照视频一步一步来敲的但就是读不出数据库里的信息
用日志文件跟踪发现代码走到Bootstrap.php文件就断掉了死活跳不到IndexAction.php文件去,推测是适配器有问题,求教各位大神

*/
//Bootstrap.php
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
public function __construct($app){
parent::__construct($app);
$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 UTF8');
Zend_Db_Table::setDefaultAdapter($db);
}
}
//application.ini
[production]
phpSettings.display_startup_errors = 0
phpSettings.display_errors = 0
includePaths.library = APPLICATION_PATH "/../library"
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
bootstrap.class = "Bootstrap"
appnamespace = "Application"
resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
resources.frontController.params.displayExceptions = 0
[mysql]
db.adapter=PDO_MYSQL
db.params.host=localhost
db.params.username=root
db.params.password=root
db.params.dbname=testzfp
//IndexController.php
require APPLICATION_PATH.'/models/Message.php';
class IndexController extends Zend_Controller_Action
{
public function init()
{
/* Initialize action controller here */
}
public function indexAction()
{
// action body
$messModel=new Message();
$res=$messModel->fetchAll()->toArray();
print_r($res);
exit();
$this->render('index');
}
}