先看一段代码,很短。(zendframework1.12框架,php-version:5.3.1)
IndexController.php
1 require_once(APPLICATION_PATH.'/models/productTestModel.class.php'); 2 class IndexController extends Zend_Controller_Action 3 { 4 5 public function init() 6 { 7 /* Initialize action controller here */ 8 $url = constant("APPLICATION_PATH").DIRECTORY_SEPARATOR.'configs'.DIRECTORY_SEPARATOR.'application.ini'; 9 $dbconfig = new Zend_Config_Ini($url, 'mysql'); 10 $db = Zend_Db::factory($dbconfig->db); 11 $db->query('SET NAMES UTF8'); 12 Zend_Db_Table::setDefaultAdapter($db); 13 //var_dump($db); 14 } 15 16 public function indexAction() 17 { 18 // action body 19 $productTestModelObj = new productTestModel(); 20 //var_dump($productTestModelObj); 21 $rs = $productTestModelObj -> fetchAll()->toArray(); 22 echo '<pre>'; 23 print_r($rs); 24 echo '</pre>'; 25 exit; 26 } 27 28 }
从数据库读取出来的数据集$rs,已经能正常的打印出来。
问题是,第21行调用"fecthAll()"这个函数,我追踪进去之后,在函数体内打印一句话,代码如下:
/zend/Db/Table/Abstract.php
1 public function fetchAll($where = null, $order = null, $count = null, $offset = null) 2 { 3 echo 'test<br />'; 4 if (!($where instanceof Zend_Db_Table_Select)) { 5 $select = $this->select(); 6 7 if ($where !== null) { 8 $this->_where($select, $where); 9 } 10 11 if ($order !== null) { 12 $this->_order($select, $order); 13 } 14 15 if ($count !== null || $offset !== null) { 16 $select->limit($count, $offset); 17 } 18 19 } else { 20 $select = $where; 21 } 22 23 ....(此处省略后面无关紧要的代码)
页面刷新后,居然没有显示“test”,这是为什么??求各位大神帮帮忙,小弟感激不尽。
自己已经解决