【发布时间】:2011-12-03 18:46:03
【问题描述】:
我的课程有问题(由 Zend_Db_Table_Abstract 扩展),它每次只返回一行,并带有一个连接和选择....
我在互联网上搜索,但我没有找到关于这个“错误”的任何内容!
class Api_Model_News extends Zend_Db_Table_Abstract
{
protected $_name = 'news';
protected $_primary = 'news_id';
protected $select;
public function init()
{
$this->select = $this->select();
}
public function setTimestamp($timestamp)
{
$this->select
->where('news_timestamp >= ?', $timestamp);
return $this;
}
public function setCategory($id_category)
{
$this->select
->where('bsn_id_category = ?', $id_category);
return $this;
}
public function getNews()
{
$this->select
->from('news')
->joinLeft('business', 'news_id = bsn_id', array());
$data = $this->fetchAll($this->select);
return $data->toArray();
}
}
在另一个函数中:
$news = new Api_Model_News();
if ($id_category != NULL)
$news->setCategory($id_category);
if ($last_sync != NULL)
$news->setTimestamp($last_sync);
return $news->getNews();
- 当我设置
id_category而不是last_sync=> 只有一行 - 当我设置
last_sync而不是id_category=> 多行 - 当我设置
last_sync和id_category=> 只有一行
为什么?我想这是因为我在select 中使用了bsn_id_category,但我不明白....
【问题讨论】:
标签: php mysql database zend-framework join