views:

14

answers:

0

I am trying to implement this method in my model:

class Application_Model_MenuProfilesProducts extends Zend_Db_Table_Abstract
{
    protected $_name = 'menu_profiles_products';

   public function fetchProducts($profileID) {
        $select = Zend_Db_Table::getDefaultAdapter()->select()
                        ->from(array('mpp' => 'menu_profiles_products'), array('NAME' => 'p.name', 'PRICE' => 'p.price*mp.added_value/100'))
                        ->join(array('p' => 'products'), 'p.id = mpp.product_id')
                        ->join(array('mp' => 'menu_profiles'), 'mp.id = mpp.profile_id')
                        ->where('mpp.profile_id = ?', $profileID);

        $adapter = new Zend_Paginator_Adapter_DbTableSelect($select);
        return $adapter;
    }
}

I get an error Unrecognized method 'getTable()'

Basically I'm trying to implement this SQL query:

SELECT p.name as NAME, p.price*mp.added_value/100 AS PRICE 
FROM `menu_profiles_products` AS mpp 
JOIN products AS p ON p.id = mpp.product_id 
JOIN menu_profiles AS mp ON mp.id = mpp.profile_id
WHERE mpp.profile_id = <a number>

Stack trace dump from zend:

#0 [internal function]: Zend_Db_Select->__call('getTable', Array)
#1 D:\wamp\www\Bucatarie\library\Zend\Paginator\Adapter\DbTableSelect.php(46): Zend_Db_Select->getTable()
#2 D:\wamp\www\Bucatarie\library\Zend\Paginator.php(755): Zend_Paginator_Adapter_DbTableSelect->getItems(0, 25)
#3 D:\wamp\www\Bucatarie\library\Zend\Paginator.php(584): Zend_Paginator->getItemsByPage(1)
#4 D:\wamp\www\Bucatarie\library\Zend\Paginator.php(1064): Zend_Paginator->getCurrentItems()
#5 D:\wamp\www\Bucatarie\library\Zend\Paginator.php(816): Zend_Paginator->_createPages('Sliding')
#6 D:\wamp\www\Bucatarie\library\Zend\View\Helper\PaginationControl.php(119): Zend_Paginator->getPages('Sliding')
#7 [internal function]: Zend_View_Helper_PaginationControl->paginationControl(Object(Zend_Paginator), 'Sliding', 'partials/pagina...')
#8 D:\wamp\www\Bucatarie\library\Zend\View\Abstract.php(342): call_user_func_array(Array, Array)
#9 [internal function]: Zend_View_Abstract->__call('paginationContr...', Array)
#10 D:\wamp\www\Bucatarie\application\modules\admin\views\scripts\menu-profiles\profile-products.phtml(44): Zend_View->paginationControl(Object(Zend_Paginator), 'Sliding', 'partials/pagina...')
#11 D:\wamp\www\Bucatarie\library\Zend\View.php(108): include('D:\wamp\www\Buc...')
#12 D:\wamp\www\Bucatarie\library\Zend\View\Abstract.php(880): Zend_View->_run('D:/wamp/www/Buc...')
#13 D:\wamp\www\Bucatarie\library\Zend\Controller\Action\Helper\ViewRenderer.php(897): Zend_View_Abstract->render('menu-profiles/p...')
#14 D:\wamp\www\Bucatarie\library\Zend\Controller\Action\Helper\ViewRenderer.php(918): Zend_Controller_Action_Helper_ViewRenderer->renderScript('menu-profiles/p...', NULL)
#15 D:\wamp\www\Bucatarie\library\Zend\Controller\Action\Helper\ViewRenderer.php(957): Zend_Controller_Action_Helper_ViewRenderer->render()
#16 D:\wamp\www\Bucatarie\library\Zend\Controller\Action\HelperBroker.php(277): Zend_Controller_Action_Helper_ViewRenderer->postDispatch()
#17 D:\wamp\www\Bucatarie\library\Zend\Controller\Action.php(523): Zend_Controller_Action_HelperBroker->notifyPostDispatch()
#18 D:\wamp\www\Bucatarie\library\Zend\Controller\Dispatcher\Standard.php(295): Zend_Controller_Action->dispatch('profileProducts...')
#19 D:\wamp\www\Bucatarie\library\Zend\Controller\Front.php(954): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http))
#20 D:\wamp\www\Bucatarie\library\Zend\Application\Bootstrap\Bootstrap.php(97): Zend_Controller_Front->dispatch()
#21 D:\wamp\www\Bucatarie\library\Zend\Application.php(366): Zend_Application_Bootstrap_Bootstrap->run()
#22 D:\wamp\www\Bucatarie\public\index.php(26): Zend_Application->run()
#23 {main}  

Please advise.