|
|||
|
Hi,
Is it possible to return a rowset instead of array with direct queries? I have these classes under models directory.(in one file) <?php class Products extends Zend_Db_Table_Abstract{ protected $_name = 'Products'; protected $_primary = 'productID'; protected $_rowClass = 'Product'; function loadIndexProducts($pCategory){ $sql = 'SELECT * FROM Products WHERE product_category=? AND productStock=1 ORDER BY rand() LIMIT 0,6'; $return = $this->_db->fetchAll($sql,$pCategory); return $return; if I run it like this, it returns array instead of rowset, and so I can't use rowclass below. } } /* Row Class */ class Product extends Zend_Db_Table_Row_Abstract{ public function getProductID(){ return $this->productID; } public function getProductCategoryName(){ $categorySet = $this->findDependentRowset('Categories'); $thisCategory = $categorySet->current(); return $thisCategory->categoryName; } public function getProductMainPic(){ $pictureSet = $this->findDependentRowset('ProductPictures'); foreach ($pictureSet as $pictureLine){ if ($pictureLine->mainPic == '1'){ return $pictureLine->imageFile; } return 'null'; } } public function __get($key){ if (method_exists($this,$key)){ return $this->$key(); } return parent::__get($key); } } ?> Thanks Bill |
![]() |
| Thread Tools | |
| Display Modes | |
|
|