Może niejasno wyraziłem się w poprzednim poście.
Zend_Db_Table jeszcze nie używam (nie znalazłem dobrego przykładu, który by mi dokładnie wytłumaczył

)
Oczywiście używam Zend_Cache, tylko chodzi mi o sposób w jaki to robie:
/**
* @category Portal
* @package Portal_News
*/
class Portal_News extends Aquila_Model_Cache_MySql implements Portal_News_Interface
{
/**
* Zwraca informacje o konkretnym newsie
*
* @param int $newsId
* @param array $options
* @return array
*/
public function getId
($newsId,array $options = array()) {
$newsId = (int)$newsId;
$query = $this->_db->select()
->from(array('n'=>'news'),'n_date') ->joinLeft(array('nt' => 'newstext'),'nt.n_id = n.n_id',array('nt_title','nt_text')) ->joinLeft(array('m' => 'members'),'m.m_id = n.m_id',array('m_id','m_name')) ->where('n.n_id = ?', $newsId)
->limit(1);
$query->where('nt.l_id = ?', $options['language']);
return $this->_select($query,'fetchRow');
}
}
Klasa "obsługi" cache
abstract class Aquila_Model_Cache_MySql
{
/**
* @var Zend_Db_Adapter_Pdo_Abstract
*/
protected $_db;
/**
* @var Zend_Cache_Core
*/
protected $_cache;
/**
* Konstruktor
*
* @param Zend_Db_Adapter $db
* @param Zend_Cache_Adapter $cache
* @return Aquila_Model_Cache
*/
public function __construct(Zend_Db_Adapter_Pdo_Abstract $db, Zend_Cache_Core $cache = null)
{
$this->_db = $db;
$this->_cache = $cache;
}
/**
* Zapytanie
*
* @param Zend_Db_Select $select
* @param string $fetchMode
* @param array $options
* @return array
*/
protected
function _select
(Zend_Db_Select
$select, $fetchMode = 'fetchAll', array $options = array()){
if($this->_cache)
{
$cacheName = md5($select->assemble());
if($data = $this->_cache->load($cacheName))
{
return $data;
}
}
switch($fetchMode)
{
case 'fetchAssoc':
$data = $this->_db->fetchAssoc($select);
break;
case 'fetchCol':
$data = $this->_db->fetchCol($select);
break;
case 'fetchfetchOne':
$data = $this->_db->fetchOne($select);
break;
case 'fetchPairs':
$data = $this->_db->fetchPairs($select);
break;
case 'fetchRow':
$data = $this->_db->fetchRow($select);
break;
case 'fetchAll':
default:
$data = $this->_db->fetchAll($select);
break;
}
if($this->_cache)
{
$this->_cache->save($data, $cacheName);
}
return $data;
}
}
Jeżeli zapytanie zapisuje wynik do cache to używam funkcji _select.
Zapytania bez cache, wywołuje bezpośrednio $this->_db->fetch...()
Pozdrawiam.