zf调用fetchAll函数的问题

JayKong 2012-09-23 08:37:14
先看一段代码,很短。(zendframework1.12框架,php-version:5.3.1)
IndexController.php
require_once(APPLICATION_PATH.'/models/productTestModel.class.php');
class IndexController extends Zend_Controller_Action
{

public function init()
{
/* Initialize action controller here */
$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);
//var_dump($db);
}

public function indexAction()
{
// action body
$productTestModelObj = new productTestModel();
//var_dump($productTestModelObj);
$rs = $productTestModelObj -> fetchAll()->toArray();
echo '<pre>';
print_r($rs);
echo '</pre>';
exit;
}

}
从数据库读取出来的数据集$rs,已经能正常的打印出来。
问题是,第21行调用"fecthAll()"这个函数,我追踪进去之后,在函数体内打印一句话,代码如下:
/zend/Db/Table/Abstract.php
public function fetchAll($where = null, $order = null, $count = null, $offset = null)
{
echo 'test<br />';
if (!($where instanceof Zend_Db_Table_Select)) {
$select = $this->select();

if ($where !== null) {
$this->_where($select, $where);
}

if ($order !== null) {
$this->_order($select, $order);
}

if ($count !== null || $offset !== null) {
$select->limit($count, $offset);
}

} else {
$select = $where;
}

....(此处省略后面无关紧要的代码)
页面刷新后,居然没有显示“test”,这是为什么??求各位大神帮帮忙,小弟感激不尽。
...全文
85 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

4,250

社区成员

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

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