2011-12-03 3 views
1

私は自分のクラスに問題があります(Zend_Db_Table_Abstractによって拡張されています)、毎回ジョインで1行しか返しません....私のZend_Db_Table_Abstractをselectとjoinで使用すると、fetchAllは1行を返します

インターネットで検索しましたが、この「バグ」に何も見つかりませんでした。別の機能において

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(); 
  • I設定id_categoryなくlast_sync = Iが設定>唯一の行
  • last_syncなくid_category =>倍数行
  • 私はlast_syncid_category => 1つだけの行を設定します

なぜですか? にbsn_id_categoryを使用していますが、私は理解できません...

どうすればいいですか? =)

Calumah

答えて

0

ビル、この試してみてください。setIntegrityCheckの有無にかかわらず

$this->select(Zend_Db_Table::SELECT_WITH_FROM_PART) 
     ->setIntegrityCheck(false) 
     ->joinLeft('business', 'news_id = bsn_id', array()); 
0

"Setting this flag to false skips the checks for table joins, allowing 'hybrid' table rows to be created"としてfalseに整合性チェックを設定しよう:最後の答えに

$this->select 
     ->setIntegrityCheck(false) 
     ->joinLeft('business', 'news_id = bsn_id', array()); 
+0

をに設定偽、私はもう一度行を得る....:/ – Calumah

関連する問題