Php zend framework选择连接错误getTable()

Php zend framework选择连接错误getTable(),php,zend-framework,zend-db,zend-db-table,zend-db-select,Php,Zend Framework,Zend Db,Zend Db Table,Zend Db Select,我正在尝试在我的模型中实现此方法: class Application_Model_MenuProfilesProducts extends Zend_Db_Table_Abstract { protected $_name = 'menu_profiles_products'; public function fetchProducts($profileID) { $select = Zend_Db_Table::getDefaultAdapter()->

我正在尝试在我的模型中实现此方法:

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;
    }
}
我得到一个错误无法识别的方法“getTable()”

基本上,我正在尝试实现以下SQL查询:

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>
请告知。

您需要

$select = $this->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;
或者如果您想使用Zend_Db_Select

$select = $this->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_DbSelect($select);
        return $adapter;

解决了的。我必须使用$adapter=new Zend_Paginator_adapter_DbSelect($select);你能用一种有助于他人的方式回答自己的问题吗?如果您这样做,您可以选择您的作为正确答案。这可能看起来很奇怪,但在这种情况下,它比删除更可取。
$select = $this->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_DbSelect($select);
        return $adapter;