我想爲所有我的表爲不同的客戶設置一個動態前綴。說我有客戶A,我的桌子將是「a_tablename」等Zend Framework Tableprefixes和連接失敗
這一切工作正常,所有設置都很好,但是,當我在Zend框架中運行連接查詢時,它從默認表中選擇「tablename」),而不是前綴。
這裏是我的代碼片段:
$select = $hours->select()
->setIntegrityCheck(false)
->from(array('h' => 'hours'), array('id', 'type', 'remark', 'minutes', 'date'))
->join(array('p' => 'projects'), 'h.project_id = p.id', array('description' => 'description', 'order_nr' => 'order_nr'))
->join(array('c' => 'clients'), 'p.client_id = c.id', array('client' => 'name'))
->where($this->db->quoteInto('h.user_id = ?', $userId, 'INTEGER'))
->where($this->db->quoteInto('h.date >= ?', $startDate))
->where($this->db->quoteInto('h.date <= ?', $endDate))
->order(array('h.date', 'h.type'));
$rows = $hours->fetchAll($select);
$this->view->hours = $rows;
此連接採用標準表(客戶端),其中非加入查詢選擇客戶a_clients'表。我錯過了什麼? 這裏是我的類擴展:
抽象Zend_Db_Table類擴展Zend_Db_Table_Abstract { 功能_setupTableName(){ 父 :: _ setupTableName(); $ prefix ='StackOverflow'; //也許從配置.. $ this->name = $前綴。 ''。 $這 - > _名稱; } }
(StackOverflow的是offcourse只是一個固定的值,但它的測試,從這裏我複製粘貼的吧:P)