在zend项目的任何地方使用select查询


Use select query anywhere in the project in zend

我想在我的模型类中使用select查询而不实例化Zend_Db::factory(),因为我已经在application.ini中给出了数据库的所有参数。我的模型类如下:

 class Application_Model_EmpIdMapper extends Zend_Db_Table_Abstract
 {
     public function checkEmpid($empId)
     {
          $select=$this->select()
                        ->from(array('tc' => 'tcs_contact'),array('tc.employee_id'));
          $table_data=$this->fetchAll($select);
          $table_data=$table_data->toArray();
          foreach($table_data as $row) 
          { 
                  // don check the condition before putting it into for each loop
                 if($row['employee_id'] == $empId)
                 { 
                    return 'true'; 
                 } 
                 else
                 {
                   return 'false';
                 }
             } 
           } 

        }

,但运行应用程序时,错误显示为

SQLSTATE[42S02]: Base table or view not found: 1146"mst2。Application_model_empidmapper '不存在。

如何解决这个问题?

将以下内容添加到Model类中:

// the actual name of the table in the database
protected $_name = 'the_name_of_your_Table_you_want_to_use';