1
一鍵我有兩個表,一個用戶表和申請表:從表中選擇行與另一個表中的Zend
User
id
username
application
id
user_id
...
爲了得到我想能夠選擇應用程序的應用通過應用程序ID或用戶名。要通過應用程序ID獲取應用程序非常簡單,但我不確定如何通過用戶名獲取應用程序。以下是我目前在我的模型中的相關代碼。
protected $_referenceMap = array (
'User' => array (
'columns' => 'user_id',
'refTableClass' => 'Application_Model_DbTable_User',
'refColumns' => 'id'
)
);
public function get_application($id) {
if(is_numeric($id)) {
$row = $this->fetchRow("id = $id");
} else {
//get application by username
}
return $row->toArray();
}