2010-09-06 68 views
1

在某些情況下Doctrine_Core::getTable('%Name%')返回 Doctrine_Table實例而不是%Name%Table之一。這顯然是一個錯誤,但除了Doctrine_Core::getTable('%Name%')之外,還有其他一些獲取表示實例的方法嗎?在原則中獲取表實例的替代方法

爲了給這種不當行爲示範:這裏是小問題 跟蹤系統的架構

User: 
    actAs: [Timestampable] 
    tableName: issue_user 
    columns: 
    user_id:  { type: integer, primary: true, autoincrement: true } 
    user_name:  { type: string(255) } 
    user_role:  { type: enum, values: [worker, dispatcher, manager] } 
    managed_by:  { type: integer } 
    password:  { type: string(32) } 
    salt:   { type: string(32) } 
    relations: 
    Manager: 
     foreignAlias: Workers 
     class: User 
     local: managed_by 
     foreign: user_id 
     type: one 
     foreignType: many 

Issue: 
    actAs: [Timestampable] 
    columns: 
    issue_id:  { type: integer, primary: true, autoincrement: true } 
    from_ceh:  { type: string(255) } 
    from_name:  { type: string(255) } 
    from_phone:  { type: string(255) } 
    from_location: { type: string(255) } 
    comp_name:  { type: string(255) } 
    comp_serial:  { type: string(255) } 
    comp_os:   { type: enum, values: [Win95, Win98, WinNT, WinME, Win2000, WinXP, Vista, Win7] } 
    issue_title:  { type: string(255) } 
    comment:   { type: string(255) } 
    owner_id:  { type: integer } 
    is_executed:  { type: bool } 
    relations: 
    Owner: 
     onDelete: CASCADE 
     foreignAlias: Issues 
     class: User 
     local: owner_id 
     foreign: user_id 
     type: one 
     foreignType: many 

當我就叫Doctrine_Core::getTable('User')返回UserTable 實例,但如果我把它叫做這樣的後查詢:

Doctrine_Query::create() 
     ->select('u.user_id, ws.user_id, i.*') 
     ->from('User u, u.Workers ws, ws.Issues i') 
     ->where('u.user_id=', $manager_id) 
     ->fetchArray(); 

調用Doctrine_Core::getTable('User')回報Doctrine_Table 例如

P.S. 1.2.3學說

+0

爲什麼不報告這個bug?和/或鏈接到bug跟蹤器? – greg0ire 2010-09-06 14:48:40

+1

我錯了,或者'fetchArray()'返回數組,不是對象嗎?全部取決於使用的hydrator。不要使用hydrator,你會得到相同的結果。 – takeshin 2010-09-06 16:10:14

回答

0

學說1.2(這聽起來像你正在使用支持XxxTable ::的getInstance()的最新版本,雖然它是所有調用主義:: getTable(「XXX」);