2011-11-01 104 views
1

我正在使用Zend 1.11和Doctrine 1.2,並試圖找到一種方法來檢索數據庫中的記錄列表,不包括最後輸入的記錄(最後一個id)。 我檢查了Doctrine文檔,但什麼都沒發現。有沒有人可以幫助我?檢索所有記錄,但最後一個與Zend和Doctrine

+0

你需要教義來做過濾嗎?返回所有記錄,並使用array_pop()從陣列中刪除最後一個元素 – Patrick

+0

是的我需要過濾的原則。不知道我怎麼可以使用array_pop。 – FFSS

+1

爲什麼學說需要這樣做? Array_pop接受一個數組並刪除最後一個元素。 http://php.net/manual/en/function.array-pop.php你可以擴展Doctrine_Collection,當你使用該集合時,最後一個元素可以自動彈出 – Patrick

回答

2

我不是一個學說用戶,但你應該使用一個訂單和一個抵消。

如果我考慮Limit and offset clausesOrder by clause,我會嘗試寫:

$q = Doctrine_Query::create() 
    ->select('u.username') 
    ->from('User u') 
    ->limit($k) // where $k is a great int, try without but I doubt this will work 
    ->offset(1) 
    ->orderBy('u.id DESC'); 

我希望它能幫助。

+0

其實 - >偏移(1)按預期工作。謝謝。讚賞。 – FFSS

+0

很好,如果有幫助! – AsTeR